-2

我在列表视图中获取选定的数组列表项时遇到了问题。这是我的代码:

ArrayList<Doctor> doctorList = new ArrayList<Doctor>();//this is the resources of my List.
setListAdapter(new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, doctorList));
@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);

        LinkedHashMap<String, Object> obj = new LinkedHashMap<String, Object>();

        Doctor aDoc=(Doctor)l.getItemAtPosition(position);//this line show error

        obj.put("hashmapkey", aDoc);
        Intent inew = new Intent(DoctorsListActivity.this,
                DoctorBioDataActivity.class);
        Bundle b = new Bundle();

        b.putSerializable("bundleobj", obj);
        inew.putExtras(b);

        startActivity(inew);
    }`

*我只是获取选定的数组列表项对象来传递下一个活动 * 请帮助..

4

1 回答 1

3

而不是使用

Doctor aDoc=(Doctor)l.getItemAtPosition(position);

像这样使用你ArrayList doctorList;的:Object

Doctor aDoc = doctorList.get(position);
于 2012-09-10T10:44:58.220 回答