我有这个自定义列表。各行包含一个图像和两行下方的其他文本之一。我想开一个新的活动的任何列表项被点击时。但我不能这样做,即使实施setOnItemClickListener后()。请纠正我,如果我错了。下面是code的名单。 PS:这是一种正常的活动,而不是单活动
l1.setAdapter(新EfficientAdapter(这一点,eventTitleArray,eventDateArray,eventImageLinkArray));
// L1 = getListView();
l1.setClickable(真正的);
l1.setOnItemClickListener(新OnItemClickListener(){
@覆盖
公共无效onItemClick(适配器视图<>为arg0,查看ARG1,
INT位置,长ARG3){
意向意图=新的意图(MainActivity.this,DisplayActivity.class);
叠B =新包();
b.putString(事件,eventTitleArray [位置]);
intent.putExtras(包);
startActivity(意向);
Toast.makeText(getApplicationContext(),打开详细视图:+ eventTitleArray [位置],Toast.LENGTH_SHORT).show();
}
});
解决方案
请看看行布局是否具有可获得焦点是任何项目。如果ListView项包含可成为焦点的儿童,列表视图处理程序不会被解雇。
i have this customized list. each row contains an image and two lines of text one below the other. i want to open a new activity when any list item is clicked. but i am not able to do so, even after implementing the setOnItemClickListener(). please correct me if i am wrong. the below is the code for the list. PS: This is an normal activity and not list activity.
l1.setAdapter(new EfficientAdapter(this,eventTitleArray,eventDateArray,eventImageLinkArray));
//l1 = getListView();
l1.setClickable(true);
l1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
Intent intent = new Intent(MainActivity.this, DisplayActivity.class);
Bundle b = new Bundle();
b.putString("event", eventTitleArray[position]);
intent.putExtras(bundle);
startActivity(intent);
Toast.makeText(getApplicationContext(), "Opening detailed view for:"+eventTitleArray[position], Toast.LENGTH_SHORT).show();
}
});
解决方案
Please have a look whether the row layout has any items which are focusable. If an ListView Item contains focusable children, the Listview Handler will not be fired.