Build CheckBox Based Alert Dialog

Put your problem here if it does not fit any of the other categories.

Build CheckBox Based Alert Dialog

Postby nxsfan » Sun Jun 13, 2010 11:08 pm

Hi, I'm sorry if I'm asking an annoying question.
I want to build an alert dialog with a bunch of checkboxes. I have achieved this by passing a string and boolean array. What I would like to do is pass the resource id for a checkbox array ie:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 CheckBox[] types = new CheckBox[3];
  2.                 types[0].setChecked(true);
  3.                 types[1].setChecked(true);
  4.                 types[2].setChecked(true);
  5.  
  6.                 types[0].setText("Red");
  7.                 types[1].setText("Blue");
  8.                 types[2].setText("Green");
  9.  
  10.         AlertDialog.Builder builder = new AlertDialog.Builder(this);
  11.                 builder.setTitle("Some Title");
  12.                 builder.setMultiChoiceItems(types_Resource_Id, checked, new DialogInterface.OnMultiChoiceClickListener()
  13.                 ....
  14.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Is what I am trying to achieve valid? If not what does the (int ItemsId) argument refer to in the .setMultiChoiceItems argument list. If it is valid then how do I get the integer resource id for an array I have just declared? (sorry if this is something I should know). I tried:

getResources().getIdentifier("types", "CheckBox", package_name), but it returns zero.

I have spent about 4 hours trawling the web for this answer and have had no luck. I understand there is something conflicting about providing an id to a CheckBox array including checked status and then also passing a boolean array of checked status so maybe I have got the wrong end of the stick.

Thank you for any help.
nxsfan
Freshman
Freshman
 
Posts: 2
Joined: Sun Jun 13, 2010 10:04 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 23 guests