我正在尝试点击listview,其中每一行都是hashmap:
lvItem = (ListView)getView().findViewById(R.id.listWork);
ArrayList<HashMap<String, String>> mylistData = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
int[] columnID = new int[] {R.id.tvPK, R.id.tvText };
map.put("PK", "1");
map.put("ITEM", "2");
mylistData.add(map);
SimpleAdapter arrayadapter = new SimpleAdapter(getActivity(), mylistData, R.layout.row_hidden_id, new String[] {"PK", "ITEM"}, columnID);
lvItem.setAdapter(arrayadapter);
lvItem.setTextFilterEnabled(true);
lvItem.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int p, long id) {
Object o = lvItem.getItemAtPosition(p);
ErrorMsg("ID:" + o.toString());
} });
我得到类似“{ITEX = 2,PK = 1}”的东西
我需要将对象(o)转换为hashmap并只获取pk ...
任何想法?
谢谢!