按钮,在列表视图 - 机器人 [英] Button in a listview - android
本文介绍了按钮,在列表视图 - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 SimpleAdapter
扩展 ListActivity
作为列表适配器类。我的code是这样的:
I have a class that extends ListActivity
with a SimpleAdapter
as the list adapter. My code looks like this:
public class ListOfFirms extends ListActivity {
Intent extras;
int time;
String km;
ArrayList<String> firms = new ArrayList<String>();
SimpleAdapter adapter;
static final ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.firms);
extras = getIntent();
time = extras.getIntExtra("time", 0);
km = extras.getStringExtra("km");
adapter = new SimpleAdapter(
this, list, R.layout.taxi_custom,
new String[] {"name","price"},
new int[] {R.id.taxi_name,R.id.taxi_price});
initializeFirm();
setListAdapter(adapter);
}
我的问题是我怎么可以在列表中添加一个按钮,每一个元素,按钮应浮动权。我的列表包含类公司
,我怎么能知道哪个对象,我从列表中抢出来的对象,当用户presses这个按钮?
My question is how I can add a button to each element in the list, the button should be floating to right. My list contains object of the class Firm
, how can I know which object that I grab out from the list, when a user presses this button?
推荐答案
的这里是示例自定义列表视图可帮助您的
here is example of custom listview which may help you
使用自定义适配器....
并设置
use custom adapter.... and set
listview.setAdapter(adapter);
这篇关于按钮,在列表视图 - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文