我有一个 ListView,其中每一行都有三个 TextView。出于某种原因,当我滚动浏览 ListView 时,我无法单击某些行。它似乎没有任何特定的模式。我最初认为这是一个焦点问题,所以我添加了一些语句以从 TextViews 中删除可点击性和焦点,但这并没有解决它。这是我的代码的相关部分:
questionsArrayAdapter = new ArrayAdapter<String>(this, R.id.number, questionsArrayList) {
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (row == null) {
// ROW INFLATION
row = inflater.inflate(R.layout.questionlistitem, parent, false);
}
TextView number = (TextView) row.findViewById(R.id.number);
TextView answer = (TextView) row.findViewById(R.id.answer);
TextView section = (TextView) row.findViewById(R.id.section);
number.setFocusable(false);
number.setClickable(false);
answer.setFocusable(false);
answer.setFocusable(false);
section.setFocusable(false);
section.setClickable(false);
这是 questionlistitem.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="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:visible="false" />
<TextView
android:id="@+id/answer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_marginRight="5dip"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingEnd="10dip"
android:paddingStart="6dip"
android:textAppearance="?android:attr/textAppearanceListItemSmall" />
<TextView
android:id="@+id/section"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:visible="true" />
</LinearLayout>
这是我的标准听众:
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
System.out.println("got clicked");
}
有谁知道是什么问题?