【发布时间】:2014-04-02 11:36:28
【问题描述】:
ListView:
<ListView android:id="@+id/list11"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:cacheColorHint="#00000000">
</ListView>
custome.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="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/txt_groupname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_weight="3"
android:text="asdasd"
android:textColor="@color/TextColor" />
<ImageButton
android:id="@+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/delete_gp"
android:focusable="false"
android:focusableInTouchMode="false" />
</LinearLayout>
Activity.java:
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
long itemValue = listView.getItemIdAtPosition(position);
Log.e("==>", "" + itemValue);
}
});
当我点击<ImageButton> 时它工作正常,但当我点击<ListView> 时它不起作用。
我该如何解决这个问题?
【问题讨论】:
-
我的 Listview 是:-
-
展示你的baseadapter。
-
@Go2 尝试
android:descendantFocusability="blocksDescendants"作为custome.xml 中的根元素 -
@Raghunandan 如果我们将所有孩子都保留为
android:focusable="false"是否需要。? :-/ -
@SilentKiller 自己试试 ImageButton
标签: android xml listview android-listview onitemclicklistener