K.Muthu K.Muthu - 7 months ago 20
Java Question

how to implement a long click listener and onclicklistener in single listview

I am creating a app in android. In that i am using list view. now i want use both click event and long click event. if is possible can any help me to do.

Answer

see this

Click & Long-Press Event Listeners in a ListActivity

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> av, View v, int pos, long id) {
        onListItemClick(v,pos,id);
    }
});

..

 lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            return onLongListItemClick(v,pos,id);
        }
    });