开发者

Implementing button click from a custom list view

开发者 https://www.devze.com 2023-01-08 00:03 出处:网络
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.

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

精彩评论

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

关注公众号