I want to create an Dialog options menu on click of a listview item. Its working perfectly when using static string array for dialog options. But using dynamic values its showing only an item with comma separated.

Here is my code

  StringBuilder builder = new StringBuilder();
        String delimiter = "";
        for(int i = 0; i< myarray.length;i++){
            builder.append(delimiter);
            builder.append(myarray[i]);
            delimiter = ",";  
        }


    String[] Options = new String[] { "Reply" ,builder.toString()};

    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle("TEst");
    dialog.setItems(Options, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {

            if (id == 0) {

            }
            if (id == 1) {

            }

        }
    });
dialog.show();
share|improve this question

46% accept rate
what is in myarray? – Candy Apr 24 at 7:58
do you create dialog in overridden onCreateDialog() method of your activity? – Tomislav Novoselec Apr 24 at 7:59
@Candy myarray is a string array pouplated from json – i leaf Apr 24 at 8:38
is there any value in it? – Candy Apr 24 at 8:40
@Candy Yes they are string values – i leaf Apr 24 at 8:50
show 1 more comment
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.