listView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int pos, long id) {
Object o = this.getListAdapter(lvAdapter).getItem(pos);
String keyword = o.toString();
makeToast("List Selected: " + pos,"#ff1111","#cfcfcf","testImage");
Log.d("ListView", String.valueOf(pos));
}});
所有其他 - 正常工作
答案 0 :(得分:1)
this
您所在的OnItemClickListener
。如果您删除this
它应该有效。或者,您可以使用MyActivity.this.getListAdapter(lvAdapter)
将MyActivity
替换为您的活动/片段名称
答案 1 :(得分:0)
更改此类代码,使用您的活动名称
更改YouaActivity
listView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int pos, long id) {
Object o = YouaActivity.this.getListAdapter(lvAdapter).getItem(pos);
String keyword = o.toString();
makeToast("List Selected: " + pos,"#ff1111","#cfcfcf","testImage");
Log.d("ListView", String.valueOf(pos));
}});
答案 2 :(得分:0)
listView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int pos, long id) {
Object o = MyActivity.getListAdapter(lvAdapter).getItem(pos);
String keyword = o.toString();
makeToast("List Selected: " + pos,"#ff1111","#cfcfcf","testImage");
Log.d("ListView", String.valueOf(pos));
}});
答案 3 :(得分:0)
谢谢朋友们: - )))
正常使用此变体:
listView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int pos, long id) {
String itemName = (String) adapter.getItemAtPosition(pos);
makeToast("List Selected: " + pos + " / " + itemName,"#ff1111","#cfcfcf","testImage");
Log.d("ListView", String.valueOf(pos));
}});