2014年2月16日 星期日

listview long press

You have to set setOnItemLongClickListener() in the ListView:
lv.setOnItemLongClickListener(new OnItemLongClickListener() {

            public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                    int pos, long id) {
                // TODO Auto-generated method stub

                Log.v("long clicked","pos: " + pos);

                return true;
            }
        }); 
The XML for each item in the list (should you use a custom XML) must haveandroid:longClickable="true" as well (or you can use the convenience methodlv.setLongClickable(true);). This way you can have a list with only some items responding to longclick.
Hope this will help you.

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...