K.Muthu K.Muthu - 1 year ago 67
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 Source

see this

Click & Long-Press Event Listeners in a ListActivity

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


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