我正在使用 SimpleCursorAdaptor 加载一个包含 2 列的列表视图。代码是:
mCursor = managedQuery(MyobiliseData.CONTENT_URI, projection, null, null, null);
//3. Attach the data to the listview using an adaptor
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.list_item_custom_font,
mCursor,
new String[]{MyobiliseData.Columns.CUSTOMER_NAME,MyobiliseData.Columns.ADDRESS},
new int[] {R.id.text1,R.id.text2}
);
listView1.setAdapter(adapter);
When an item in the list is selected I am trying to access the data, but I am not sure what type of object to use - when I use a HashMap object, it fails, ie
HashMap<String, String> item = (HashMap<String,String>) listView1.getAdapter().getItem(position);
非常感谢任何帮助。
谢谢