ListView, mark the position where the user touches

后端 未结 3 1113
谎友^
谎友^ 2021-01-17 00:53

I have a custom listview with a setOnTouchListener

view.setOnTouchListener(new OnTouchListener() {

        @Override
        publi         


        
3条回答
  •  广开言路
    2021-01-17 01:34

    If you want to highlight ListView item on click/touch than it's better to use selectors instead of overiding OnTouchListener().

    If you want to set the color, you need a StateListDrawable. You can set this on your list using the android:listSelector attribute, defining the drawable in XML:

    
    
      
      
      
    
    

    Or you can use the same selector for item of the ListView.

提交回复
热议问题