I am loading a listview with 2 columns using a SimpleCursorAdaptor. The code is:
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, i.e.
HashMap<String, String> item = (HashMap<String,String>) listView1.getAdapter().getItem(position);
Any help most appreciated.
thanks
you can get item on a particular index from cursor, use as follows: