简体   繁体   中英

How I can make a list view to send touch events to the items in Android?

I need to implement custom elements in a list view.

Each list element has more custom elements inside that need to receive the touch events. The problem is that I only receive MotionEvent.ACTION_DOWN and I want to receive MotionEvent.ACTION_MOVE .

Is there a solution to prevent the list from stealing the touch events?

I'm not sure what you're looking for. If you mean a list view with custom clickable elements try this tutorial, was very helpful to me, Android Hive - custom ListView .

You have just to implement:

ListView list;

list.setOnItemClickListener(new OnItemClickListener() {
     @Override
     public void onItemClick(AdapterView parent, View view, int position, long id) {
         //your code here

     }
 });

Finally if you want to try something different take a look also at this library .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM