我正在使用一个像这样设置的ListView:
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:longClickable="false"
android:choiceMode="singleChoice">
</ListView>
在我的代码中,我像这样向ListView添加了一个OnItemSelectedListener:
getListView().setAdapter(adapter);
getListView().setOnItemSelectedListener(this);
我的Activity像这样实现了监听器:
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Log.d("Tag", "ListItemSelected: Parent: " + parent.toString() + " View: "
+ view.toString() + " Position: " + " Id: " + id);
}
我原本希望在单击列表中的某个内容时能看到这个调试输出,但是LogCat中从未显示出来。