Code Painters The Art of Coding

17Dec/092

Android 1.5 and ListView’s choiceMode

I've just discovered that setting the choiceMode attribute of the ListView element in the XML layout doesn't work on Android 1.5. Comparing ListView.java from 1.5 and 1.6 releases reveals the following difference (among others):

@@ -166,6 +174,8 @@
             setDividerHeight(dividerHeight);
         }

+        setChoiceMode(a.getInt(R.styleable.ListView_choiceMode, CHOICE_MODE_NONE));
+
         mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
         mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

The change is inside ListView's constructor. Looks like someone has forgotten to add the code to retrieve the choiceMode attribute, and that was fixed in 1.6. I've found no ticket for that in the Android tracker, however.

Anyway, if you want your code to be 1.5-compatible, you'd rather call setChoiceMode() explicitly in your code.

Share:
  • Facebook
  • Digg
  • del.icio.us
  • Twitter
  • LinkedIn
  • Google Bookmarks
  • Reddit
  • StumbleUpon
Comments (2) Trackbacks (0)
  1. I really enjoy the quality information you offer to your visitors… Will be back often to check up on new stuff you post!

  2. I really like this blog. Please continue the great work. Regards!!!


Leave a comment

No trackbacks yet.