【发布时间】:2015-07-29 13:20:23
【问题描述】:
我在编写这部分代码时遇到了一个错误:
ListView lv = (ListView) this.findViewById(R.id.toDoListView);
lv.setAdapter(tdla);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent newIntent = new Intent(this, DisplayMessageActivity.class);//<--- Cannot resolve constructor
newIntent.putExtra(EXTRA_MESSAGE, "TETTE");
startActivity(newIntent);
}
});
我认为 Intent 构造函数应该与在链接到 Button 的简单函数中声明它相同:
public void sendMessage(View view){
Intent newIntent = new Intent(this, DisplayMessageActivity.class);//<--- OK
...sth...
startActivity(newIntent);
}
How to handle the click event in Listview in android? 也显示了一个类似的示例,但我无法弄清楚我缺少什么。
【问题讨论】:
标签: android listview android-intent