solution found by making CharSequence[] friendsNames = new CharSequence[friendArray.length];
simple thing.. but did not strike me.. coz i am php developer lol !!... On Jun 3, 10:04 pm, Jake <[email protected]> wrote: > hi there, > > i wanted to create a dynamic multi selection alert dialog, currently > it only supports for hard coded values i think ?... i have tried > several ways and very much unsuccessful till now .. > > i am fetching the values in JSON format and converting to JSONArray. > but how to input this to builder.setMultiChoiceItems, because it takes > only itemId from xml, cursor, or charsequence. i tried all ways i can > think of for chaging the array to charsequence.. eclipse did not > showed the error but app crashed in android throwing the cast > exception ... > > below is the code, any help / suggestion would highly help !! > thankyou!.. (i am new to both java and andriod) > > Button buttonFriends = (Button) > findViewById(R.id.buttonFriends); > > JSONObject friends = > jObject.getJSONObject("friends"); > JSONArray friendsArray = > friends.names(); > CharSequence[] friendsNames = null; > for (int i=0; i < > friendsArray.length(); i++) { > > if(friends.getString(friendsArray.getString(i)) != null) { > //friendsNames[i] = > friends.getString(friendsArray.getString(i)); > } > } > > buttonFriends.setOnClickListener(new > OnClickListener() { > > @Override > public void onClick(View > arg0) { > // TODO > Auto-generated method stub > > AlertDialog.Builder > builder = new > AlertDialog.Builder(checkin.this); > > builder.setTitle("Select your friends"); > > builder.setMultiChoiceItems(friendsNames, null, new > DialogInterface.OnMultiChoiceClickListener() { > > @Override > public void > onClick(DialogInterface arg0, int arg1, > > boolean arg2) { > // > TODO Auto-generated method stub > > } > }); > AlertDialog alert = > builder.create(); > alert.show(); > } > > }); -- 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

