<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:orientation="horizontal"
android:layout_width="fill_parent"
android:clickable="false"
android:focusable="false">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:clickable="false"
android:focusable="false"
android:orientation="vertical" >
<TextView
android:id="@+id/MXname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:focusable="false"
android:gravity="left"
android:text="Slashdot"
android:textStyle="bold" />
<TextView
android:id="@+id/MXtnumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:focusable="false"
android:gravity="left"
android:text="10 minutes ago" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="false"
android:focusable="false"
android:orientation="vertical"
android:gravity="right"
android:descendantFocusability="blocksDescendants">
<ImageView
android:id="@+id/MXdialer"
android:layout_width="35dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:clickable="true"
android:focusable="true"
android:gravity="right"
android:src="@drawable/lcall_button" />
</LinearLayout>
</LinearLayout>
我有一个列表视图,上面列出了 ROW xml,下面是来自活动的代码:
@Override
public void onItemClick(AdapterView<?> parent, View view, int position , long id)
{
Log.d("ItemClick","in the list"+ String.valueOf(view.getId()));
if (view==findViewById(R.id.MXdialer))
{
Toast.makeText(this, "Name and/or Phone number empty"+String.valueOf(id), Toast.LENGTH_LONG).show();
}
}
Logcat 确实表明 onitemClick 正在执行,但 toast 永远不会起作用,并且 view.getid() 总是返回-1。我已阅读 onitemclicklisterner 上的文章,并且已经将所有视图设为不可聚焦且不可点击,但仍然不行。请建议