如何添加事件处理ListView中每一行 [英] How can I add event handling in each row in ListView
本文介绍了如何添加事件处理ListView中每一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建的CursorAdapter为我的ListView提供数据。
I create a CursorAdapter to provide data for my ListView.
我实现bindView()方法,在我的列表视图的一排显示的数据。
可是在我bindView年底,我添加一个clickListener它。但是,当我在模拟器中运行它,我看不出有任何的print语句。
I implement the bindView() method to show data in a row of my Listview. But at the end of my bindView, I add an clickListener to it. But when I run it on emulator, I don't see any print statement.
能否请你告诉我如何在ListView控件添加事件处理在一排?
Can you please tell me how to add event handling in a row in ListView?
view.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
System.out.println (" getting an onclick event....");
}
});
没有单独的行
推荐答案
您可以附加OnItemClickListener到ListView。
You could attach OnItemClickListener to the ListView - not the rows individually.
listView.setOnItemClickListener( new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View view, int arg2, long arg3) {
Log.d("TAG", "Clicked");
}
});
这篇关于如何添加事件处理ListView中每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文