I am making a checklist type app in Android, in which I am populating items in a list view with a check box next to them. when a user clicks on an item I want it to strike out the text and update the entry in the database for the relevant column. For this reason I am storing Name-Value pairs in a TreeMap. Where Name corresponds to the Database Column Name and Value to the value in that Column name. I have achieved this using the following:
if ((c.getString(c.getColumnIndexOrThrow("Field130"))).length() > 3) {
String D11 = c.getString(c.getColumnIndexOrThrow("Field130"));
map.put("Field130", D11);
}
Now I want to display the name in one textview of the corresponding listview and value in the second textview. I tried the following:
ArrayList<TreeMap<String, String>> mylist = new ArrayList<TreeMap<String, String>>();
mylist.add(map);
ListView list = (ListView) findViewById(R.id.list);
ArrayList<String> list1 = new ArrayList<String>(map.values());
dataAdapter = new ArrayAdapter<String>(this,R.layout.chklistlayout,R.id.textView1, list1);
list.setAdapter(dataAdapter);
However I am not able to get the desired results, as I get only the Values displayed. Is there no way that I can map my TreeMap directly to the listview? I am open to ideas which are more robust, even if that means reworking my whole code.