如何设置onListItemClick侦听器,以便i只能从下面设置的适配器返回R.id.number中的值。我稍后会将获得的值传递给另一个活动。请帮助
sd=new SimpleAdapter(MainActivity.this,alist,R.layout.item_list,new String[]{"No","Name"},new int[]{R.id.number,R.id.item_name});
list.setAdapter(sd);
答案 0 :(得分:3)
试试这个
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
String number=((TextView)view.findViewById(R.id.number)).getText().toString();
}
});