Sunday, 15 August 2010

Dialog with check boxes in android -


I would like to know that I can apply to communicate with the list of elements where I can choose only 4 box How can I do that? Any tutorials? I have something like:

  Protect [zero showSelectMeasurementsDialog () {boolean] checkedMeasurements = new boolean [measurements.length]; Int count = Measurement Length; (Int i = 0; i & lt; counts; i ++) Checked measurement [i] = Selected measurement. Canton (measure [ii]); DialogInterface.OnMultiChoiceClickListener Mapandialaglistonr = new DialogInterface.OnMultiChoiceClickListener () {@Override on public zero (elected dialog interface dialog, Int, which Buleyn Measurement Chekarj) {if (Hakasesekted Measurements Checkered) selected measurements. Add (measure [joe]); Else {selectedMeasurements.remove (measure [which]); } On Change Select Measurement (); }}; AlertDialog.builder Builder = New AlertDialog.Builder (this); Builder.setTitle ("Select Measure"); Builder. Settlement ChoiceIits (Measurement, Checked Measurement, Measurement Dialog Listener); AlertDialog dialog = builder.scent (); Dialog.show (); }   

But I do not know how can I select an item when I select 4?

is in such a way as to try it.

  public void dialog (View v) {string str [] = { "yyyy", "xxxx", "ccccc", "cxcxxc", "dadfssaas"}; Last AlertDialog. Builder WarningDialog = New AlertDialog Builder (main activity.); Layout Inflator Inflar = Milenite Inflator (); View View = inflater.inflate (R. diarrhea, vacant); ListView lv = (ListView) view.findViewById (R.id.listView1); ArrayAdapter & LT; String & gt; ADP = new ArrayAdapter & LT; String & gt; (GetApplicationContext (), android.R.layout.simple_list_item_multiple_choice, str); Lv.setAdapter (ADP); Last Boolean [] checked = new bullion [str.length]; alertDialog.setMultiChoiceItems (str, checkedItems, New DialogInterface.OnMultiChoiceClickListener () {@Override public void onClick (DialogInterface communicate, integer, boolean isChecked) {// TODO Auto-generated method stub int count = 0; (int i = 0; I & lt; checkedItems.length; i ++) {// checkedItems loop through array, if checkedItems // increments count * / if (checkedItems [i]) {count ++;} if (== 5 count) {// If the number of checked items becomes // four, the last checkedItems item is set to 'wrong' and the checkbox checkedItems correct marks [Joe] = false ;. ((Ale rtDialog) dialog) .getListView () setItemChecked (which is false); break;}}}}); AlertDialog.show (); }    

No comments:

Post a Comment