【发布时间】:2014-07-16 13:57:39
【问题描述】:
我有一个带有列表视图的小型 Android 应用程序。有时列表视图不会对我的输入做出反应。我可以看到我触摸了一个项目(当我触摸它时它会改变颜色),但程序什么也不做。 这是我的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:focusableInTouchMode="false" >
<TextView
android:id="@+id/textViewRowLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textSize="50sp" />
<TextView
android:id="@+id/textViewTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/textViewRowLable"
android:gravity="right"
android:textSize="25sp" />
<TextView
android:id="@+id/textViewRemainingTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/textViewTime"
android:layout_toRightOf="@id/textViewRowLable"
android:gravity="right"
android:textSize="25sp" />
</RelativeLayout>
这是监听器:
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(), "click", Toast.LENGTH_LONG).show();
}
});
有人可以告诉我为什么它并不总是有效吗?
谢谢
【问题讨论】:
标签: android listview onitemclicklistener