Miha,

On Tuesday, May 21, 2013 12:57:38 PM UTC+4, Miha wrote:
>
> Kostya, how do you handle "checked" states then? I see two possible 
> solutions: 
>
> 1) in OnItemClickListener, call adapter.setChecked(position), which 
> sets the checked item position and then calls notifyDataSetChanged() 
> 2) in OnItemClickListener call setChecked on the view itself plus call 
> adapter.setChecked(position) and define the checked state in the 
> getView() 
>

I call setChecked directly, because my "checkbox" tracking is in the same 
layout (although it's not a checkbox)

To track selected items (for getView to do the right thing during 
scrolling, and to know what items user actions apply to), I'm using a 
LongSparseArray... Don't think it matters much (except ListView tracks 
checked items by position, whereas I prefer "stable" database IDs).

I'm not using any choice modes inside ListView, because I also have an 
ActionMode UI implementation for Android 2.*, and it's abstracted away from 
the actual list... I guess the usefulness of sharing this is starting to 
rapidly diminish :)

 

>
> I see option 2 as a minor performance improvement over option1. How 
> did you handle it? 
>
> @Romain, is there a way to use state_activated in API level 10 via 
> some sort of compatibility package? Could I create such a 
> compatibility lib myself perhaps? 
>

In my experience the resource system will filter out attributes that aren't 
present in the actual runtime platform... So for example, you can use 
android:actionBarStyle=... when running on 2.*... and I expect 
android:attr_activated is the same way.

-- K

 

>
> Regards, 
>  Miha. 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to