Disable Click Event on Android ListView Items

前端 未结 10 1858
失恋的感觉
失恋的感觉 2021-02-05 04:13

I\'m trying to disable multiple click events on listview, say after pressing first click some media gets played from webservice, while it gets played, other items need to be

相关标签:
10条回答
  • 2021-02-05 04:32

    create Adapter for that list, and there override this method

    public boolean isEnabled(int position);
    

    then return false when you want to disable the click

    0 讨论(0)
  • 2021-02-05 04:32

    If what you want is just to diable items being clickable and show the appropriate selector color just use the line

    android:listSelector="@android:color/transparent"

    in you listview in the layout file(xml)

    0 讨论(0)
  • 2021-02-05 04:35

    Manage Click event using flags.

    While your media player is running set click to false by using this method.

    setClickable(false);
    

    When your media player is stop or not running or on complete set that flag to default value.

     setClickable(true);
    
    0 讨论(0)
  • 2021-02-05 04:35

    listView.getChildAt(position).setEnabled(false);

    listView.getChildAt(position).setClickable(false);

    0 讨论(0)
  • 2021-02-05 04:38

    the above said answers didn't worked for me, so I used list.setEnabled(false) Its worked for me

    0 讨论(0)
  • 2021-02-05 04:41

    In your custom ArrayAdapter overide isEnabled method as following

    @Override
    public boolean isEnabled(int position) {
        return false;
    }
    
    0 讨论(0)
提交回复
热议问题