设置OnListItemClick侦听器

时间:2013-05-09 06:00:06

标签: android listview simpleadapter

如何设置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);

1 个答案:

答案 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();
    }
});