我如何可以将一个侦听器的ListView? [英] How can i attach an listener to listview?
本文介绍了我如何可以将一个侦听器的ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个的ListView
与每行有一个的TextView
和三个的EditText
。当我对个别行中单击的ListView
一个活动已启动,并且带你到另一个页面。
I have a ListView
with a custom layout for each row having one TextView
and three EditText
. When I am clicking on individual row in ListView
one activity is started and that takes you to another page.
我写了一些code,但它不工作。在code如下图所示。
I wrote some code but its not working. The code is shown below.
在适配器类getView()方法,我有地方低于code
In adapter class getView() method i have place the below code
convertView = mInflater.inflate(R.layout.editcategorylist, null);
convertView.setClickable(true);
convertView.setOnClickListener(clickListener);
和我宣布点击监听器,你ListActivity如下:
and I declare the click listener in your ListActivity as follows
lv=getListView();
myClickListener = new OnClickListener(){
public void onClick(View v) {
Intent intent = new Intent(CategoryList.this,AddSubCategoryList.class);
startActivity(intent);
}
};
感谢您。
推荐答案
使用这样的事情
lv.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
public void onItemSelected(AdapterView parentView, View childView, int position, long id)
{
//Here write your code for starting the new activity on selection of list item
}
public void onNothingSelected(AdapterView parentView)
{
}
});
这篇关于我如何可以将一个侦听器的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文