user interface - Android ListView does not Highlight when a OnClickListener is set -
i have listview populated custom xml listitems, xml:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="?android:attr/listpreferreditemheight" android:padding="6dip"> ... </relativelayout> the listview shows correctly on screen , if click or hold on item becomes blue (i'm using holo light theme)
the problem comes when try assign onclicklistener view, inside getview in activity extends baseadapter:
@override public view getview(int position, @nullable view convertview, viewgroup parent) { ... convertview = inflateutils.inflate(mcontext, r.layout.list_item); ... convertview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { toast.maketext(mcontext, "test", 2000).show(); } }); ... } after doing that, list item highlight color no more shown, when click or hold on list item it's background stays white, anyway onclicklistener working.
do have suggestion highlight color while keeping default styles of hololight?
you may want use onitemclicklistener on listview itself, instead of separate click listeners item views.
also, highlight problem has been described here: android listview no longer highlights selection onclick
Comments
Post a Comment