ListActivity
我有一个以 aSimpleAdapter
作为列表适配器扩展的类。我的代码如下所示:
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);
}
我的问题是如何为列表中的每个元素添加一个按钮,该按钮应该向右浮动。我的列表包含类的Firm
对象,当用户按下此按钮时,我怎么知道我从列表中取出哪个对象?