开发者

Implementing button click from a custom list view

I am using one class which extends ListActivity and One class extending BaseAdapter. The Base Adapter uses getView function to inflate lay开发者_StackOverflow中文版out from xml. The xml contains a text and a button to delete the row of list. Please let me know how to handle the button click in the ListActivity class. Send me a sample snapshot Thanks


just create an on click listener for the item that you want to in your get view.

For instance

public class FooAdapter extends ArrayAdapter<T>
////stuff

public View getView(int position, View convertView, ViewGroup parent)
{
list.get(position)
Button b = (Button)findViewById(R.id.button)
b.setOnClickListener(l)//l is a View.OnClickListener type
}

that will render a listener for each button in the view

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜