Or could anyone who can teach me how to get the position of CheckedTextView
in its OnClickListener callback? If I can do this it means I can monitor
user actions by my own.

On Tue, Jun 22, 2010 at 8:41 PM, Alex Xin <xinxi...@gmail.com> wrote:

> Hi, guys
>
> I'm now developing an application that uses a ListView with a
> CheckedTextView on every item that managed by an ArrayAdapter to
> support multiple chooses. The contents in my ListView are dynamic, that
> means, can be changed during runtime. Now I try to use
> ListView.getCheckedItemPositions() to get all checked items, Because I want
> to save all the checked positions and auto-check them when user go back to
> this page again. So I need to save checked results for every page.
>
> Here is code that I uses to retrieve the checked item positions:
>
> public void addDirSel(String dir, ListView lv) {
>  List<Integer> l = null;
> SparseBooleanArray positions = lv.getCheckedItemPositions();
>  for(int index =0 ; index < lv.getCount(); index++) {
> if (positions.get(index, false) == true) {
>  if (l == null) {
> l = new ArrayList<Integer>();
> }
>  l.add(index);
> }
> }
>  addDirSel(dir, l);
> }
>
> My questions is:
>
> For the first page everything works fine as expected. But when user goes to
> another page and make some chooses, the result array that ListView returned
> contains some positions that are never checked. I don't why ListView has
> this strange behavior. Even for a page that in fact no checked happens but
> ListView gives me a result that indicates there's one item has been checked.
>
> Thanks for your help
> Alex,
>

-- 
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

Reply via email to