Skip to content Skip to sidebar Skip to footer

Add Your Own Listener To A List

i tried to add a listener to that list but nothing i don't understand why if you want to see the rest of the code please check on add your own listener to a list public void onCre

Solution 1:

if the ListView has focusable items then onClickListener will fire instead of the onItemClickListener. Set items can focus to false

list.setItemsCanFocus(false);

have a look at this thread. Also note there are workarounds for this. But the better choice would be to set items non focusable and use OnItemClickListener, or make them focusable and use an onClickListener on the views

Also, the onClickListener should not be set for the listview. Instead for each listview item in the getView() method

@OverridepublicViewgetView(int position, View convertView, ViewGroup parent) {
    // ...

    view.setOnClickListener(newOnClickListener() {

        @OverridepublicvoidonClick(View v) {
            // your code
        }

    });

    return view;
}

Post a Comment for "Add Your Own Listener To A List"