Bug 985875 - Set selected item in adapter for single select lists. r=bnicholson, a=lsblakk
authorWes Johnston <wjohnston@mozilla.com>
Tue, 25 Mar 2014 22:44:08 -0700
changeset 192464 4a240a67ae7d78ab79aad2c7e28754f4949ac192
parent 192463 b64ed600b9edb61124fe0c5c8fcd5719296981cd
child 192465 08574bbc72a68c1223966d2426ba7eecd7707a56
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson, lsblakk
bugs985875
milestone30.0a2
Bug 985875 - Set selected item in adapter for single select lists. r=bnicholson, a=lsblakk
mobile/android/base/prompts/Prompt.java
--- a/mobile/android/base/prompts/Prompt.java
+++ b/mobile/android/base/prompts/Prompt.java
@@ -262,16 +262,25 @@ public class Prompt implements OnClickLi
      * @param listItems
      *        The items to add.
      */
     private void addSingleSelectList(AlertDialog.Builder builder, PromptListItem[] listItems) {
         mAdapter = new PromptListAdapter(mContext, R.layout.select_dialog_singlechoice, listItems);
         builder.setSingleChoiceItems(mAdapter, mAdapter.getSelectedIndex(), new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
+                // The adapter isn't aware of single vs. multi choice lists, so manually
+                // clear any other selected items first.
+                ArrayList<Integer> selected = mAdapter.getSelected();
+                for (Integer sel : selected) {
+                    mAdapter.toggleSelected(sel);
+                }
+
+                // Now select this item.
+                mAdapter.toggleSelected(which);
                 closeIfNoButtons(which);
             }
         });
     }
 
     /* Shows a single-select list.
      *
      * @param builder