Reputation: 137
I want to change the background color of clicked ListView Item in my Android app(Dont want to use ClickOnListener implementation).I am adding my Layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minHeight="48dp"
android:paddingLeft="10dp"
>
<TextView
android:id="@+id/tv_item"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/homeButtonTextSize"
android:layout_gravity="center_vertical"
></TextView>
</LinearLayout>
I used some selectors.But not able to produce required output.Also try with "android:activatedBackgroundIndicator" .But doesnt works. Please Help me
Thanks in Advance
Upvotes: 0
Views: 270
Reputation: 38595
Use the android:listSelector
attribute on your ListView and point to a <selector>
drawable. Also, you should not use an OnCLickListener for each row, use an OnItemClickListener
instead (with ListView.setOnItemClickListener()
Upvotes: 1