I am having trouble with a list aspect of my app. Essentially, it has a multiple choice listview(simple_list_item_multiple_choice) on the right and a text view on the left.
When an item of the list view is checked off, I want to add it to the text view or remove it if it gets unchecked. This almost works except that the updates on what is checked seems to be one click behind. I.E. check something off the first time and nothing happens. Uncheck it or check something else and the first thing appears. Check below the list choices (but still in the list view) and it updates. I was not able to get setOnItemSelectedListener to respond as all, so I am using onTouchListener: private void loadContacts(){ String[] contacts = new String[] {People.NAME}; final String[] cols = new String[] { Contacts.People.NAME, Contacts.People._ID, Contacts.People.NUMBER }; final Cursor C = getContentResolver().query (People.CONTENT_URI, cols, null, null, null); startManagingCursor(C); lv = (ListView)findViewById(R.id.contact_list); ListAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, C, cols, new int[] {android.R.id.text1} ); lv.setAdapter(mAdapter); tv = (TextView)findViewById(R.id.contact_text); lv.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { chosen = lv.getCheckedItemPositions(); updateAttendance(chosen, C); //C.moveToPosition(lv.getCheckedItemPosition()); //tv.append(C.getString(0)); tv.invalidate(); return false; } }); //lv.setItemsCanFocus(false); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); lv.invalidate(); } private void updateAttendance(SparseBooleanArray array, Cursor c) { tv.setText("Chosen Ones:\n"); boolean inLoop = c.moveToFirst(); while(inLoop) { if(array.get(c.getPosition() ) ) { tv.append(c.getString(0) + "\n"); } inLoop = c.moveToNext(); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---