onListItemClick and CheckedTextView not respoding
I got ListActivity
, each item has 2 textviews image and CheckedTextView
. I am trying to implement simple multichoiselist...
I ha开发者_运维百科ve two problems:
1.
@Override
protected void onListItemClick(android.widget.ListView l, View v,
int position, long id)
{
...
}
doesnt respond at all I have tried it with the debugger and when I press on any list item it doesnt stop there. and I have tried all kind of things (like focusable:false
)
two:.
I cant toggle the CheckedTextView
anyhow.
here is my xml:
<?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="100sp"
android:focusable="false" android:focusableInTouchMode="false">
android:padding="6dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="fill_parent" android:src="@drawable/icon"
android:id="@drawable/icon" android:layout_marginLeft="6dip"
android:focusable="false" android:focusableInTouchMode="false">
</ImageView>
<LinearLayout android:id="@+id/LinearLayout01"
android:orientation="vertical" android:layout_width="1sp"
android:layout_height="fill_parent" android:layout_weight="1"
android:focusable="false" android:focusableInTouchMode="false">
<TextView android:id="@+id/toptext" android:layout_weight="1"
android:gravity="center_vertical" android:text="OrderNum"
android:singleLine="true" android:layout_height="0dp"
android:layout_width="wrap_content" android:focusable="false"
android:focusableInTouchMode="false">
</TextView>
<TextView android:id="@+id/bottomtext" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:focusable="false"
android:focusableInTouchMode="false" android:text="TweetMsg">
</TextView>
<TextView android:id="@+id/twittLocation"
android:layout_weight="1" android:text="location" android:singleLine="true"
android:layout_width="fill_parent" android:layout_height="0dip"
android:focusable="false" android:focusableInTouchMode="false">
</TextView>
<TextView android:layout_weight="1" android:id="@+id/twittLocationlink"
android:text="locationlink" android:gravity="fill_horizontal"
android:layout_width="fill_parent" android:layout_height="0dip"
android:focusable="false" android:focusableInTouchMode="false">
</TextView>
</LinearLayout>
<CheckedTextView android:id="@android:id/text1" android:text="Delete"
android:layout_width="wrap_content" android:layout_marginRight="2dp"
android:layout_height="fill_parent"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:focusable="false"></CheckedTextView>
</LinearLayout>
any idea what's the problem? thanks.
In your ListView set android:descendantFocusability="beforeDescendants"
. This might help.
Try this code:
public class Sample extends ListFragment implements OnItemClickListener{
ListView list;
list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
}
});
}
Sample code
精彩评论