我有一个填充 ListView 的 SimpleAdapter,但是当用户按下一个项目时,我希望能够获取用于填充单击的行的原始 HashMap。不幸的是,我似乎只能得到一个只支持 toString() 的对象。从用户单击的视图中获取字符串是没有用的,因为它不是唯一标识符。
如何获取用户单击的行的数据?
ArrayList<HashMap<String, String>> reformedBundle = new ArrayList<HashMap<String, String>>();
// [...]
mResultsAdapter = new SimpleAdapter(this,
reformedBundle, R.layout.resultrow,
new String[] { "ProviderName", "Street", "City" },
new int[] { R.id.tvField1, R.id.tvField2, R.id.tvField3
});
lvResults.setAdapter(mResultsAdapter);
lvResults.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
// Here's where I want to get the original HashMap<String, String> so I can query other keys in the HashMap
}
});