+ Reply to Thread
Results 1 to 2 of 2

Thread: How can I use spinner setOnItemLongClickListener

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    8

    How can I use spinner setOnItemLongClickListener

    I am trying to make the Spinner behave different way when the user clicked on an item for a long time. I have spinner with some project and I want two things.

    When the user simple click on an item I want to normal select it.
    When the user have long clicked on an item I want to show dialog, with options like "Edit item", "Delete item".
    The first step works well (ofcourse), but when I am trying to do the second task I can not make spinner to generate longClicked event.

    Here is my code:
    Code:
        this.projectSpinner = (Spinner) this.findViewById(R.id.SpinnerProjects);
        this.projectSpinner.setLongClickable(true);
    
        this.projectSpinner.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
            public boolean onItemLongClick(AdapterView<?> arg0, 
                                           View arg1, 
                                           int arg2, 
                                           long arg3) {
                Toast.makeText(
                     AndroidTimeTrackerMainActivity.this, 
                     "Long click", 
                     Toast.LENGTH_SHORT).show(); // This toast doesn't show up.
                return false;
            }
    
        });

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    15
    Spinner does not support, currently, OnItemLongClickListener.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts