Skip to main content

Posts

Showing posts with the label viewgroup

Getting the Selected View from ListView

I am using a CursorAdapter to handle my ListActivity: public class Mclass extends ListActivity{ ... TheAdapter mAdapter; public static HashMap<Long, Boolean> shown = new HashMap<Long, Boolean>(); ... @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Boolean tmp = shown.get(id); if (tmp == null) { // if null we don't have this key in the hashmap so we added with the value true shown.put(id, true); } else { shown.put(id, !tmp.booleanValue()); // if the value exists in the map then inverse it's value } mAdapter.notifyDataSetChanged(); } } And my adapter class extends CursorAdapter and overrides bindView @Override public void bindView(View view, Context context, Cursor cursor) { String listText= cursor .getString(cursor .getColumnIndexOrThrow(DataHandler.MY_TEXT)); long id = curs

Getting the Selected View from ListView

I am using a CursorAdapter to handle my ListActivity: public class Mclass extends ListActivity{ ... TheAdapter mAdapter; public static HashMap<Long, Boolean> shown = new HashMap<Long, Boolean>(); ... @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Boolean tmp = shown.get(id); if (tmp == null) { // if null we don't have this key in the hashmap so we added with the value true shown.put(id, true); } else { shown.put(id, !tmp.booleanValue()); // if the value exists in the map then inverse it's value } mAdapter.notifyDataSetChanged(); } } And my adapter class extends CursorAdapter and overrides bindView @Override public void bindView(View view, Context context, Cursor cursor) { String listText= cursor .getString(cursor .getColumnIndexOrThrow(DataHandler.MY_TEXT)); long id = curs