Let's start by explaining the features I want to achieve:
Click on an item to change its color. If there are many examples of changes online, I will not swim. The ListView is not responding because the Middle Green section (one of its own definitions of inherited Baseadapter adapter to fit the ListView) overwrites the ListView item. Now just click on the Convertview in the custom adapter.
Second, a custom adapter contains a ImageView and two textview. The code is as follows:
<?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="Wrap_content"
android:background="#fcfcfc"
android:orientation="Vertical"
android:padding="6DP"
android:descendantfocusability="blocksdescendants">
<relativelayout
Android:layout_width="Match_parent"
android:layout_height="60DP"
android:background="@drawable/mm_listitem"
android:focusable="false"
android:gravity="center_vertical" >
<imageview
android:id="@+id/userphoto"
Android:layout_width="55DP"
android:layout_height="55DP"
android:layout_alignparentleft="true"
Android:layout_centervertical="true"
android:paddingleft="5DP"
android:src="@drawable/xiaohei" />
<textview
android:id="@+id/friendname"
Android:layout_width="Wrap_content"
android:layout_height="Wrap_content"
android:layout_torightof="@id/userphoto"
android:padding="7DP"
android:textcolor="#000" />
<textview
android:id="@+id/sendtime"
Android:layout_width="Wrap_content"
android:layout_height="Wrap_content"
android:layout_alignparentright="true"
android:padding="7DP"
android:textcolor="#666" />
<textview
android:id="@+id/friendstate"
Android:layout_width="Wrap_content"
android:layout_height="Wrap_content"
android:layout_alignparentbottom="true"
android:layout_torightof="@id/userphoto"
android:padding="7DP"
android:textcolor="#666" />
</RelativeLayout>
</LinearLayout>
Workaround:
Add the LinearLayout in the XML above
Android:descendantfocusability= "Blocksdescendants"
That can be resolved.
Then click on the item that can be clicked on toast.
The custom adapter GetView did not make any changes.
[Turn]android in the ListView click event Expires