Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am populating JSON parsed data into Dialog, like this:

String[] colors = new String[] {cArrayList.toString()};
Log.d("colors::-", Arrays.toString(colors));

GETTING

enter image description here

EXPECTED

enter image description here

share|improve this question
    
String[] colors = new String[]{ cArrayList.size() }; What are you attempting to do here? Create an array of Strings of that size or put the size of that arraylist as the first element in the colors array? – Marc Baumbach Sep 19 '15 at 5:06
up vote 2 down vote accepted

As per your requirement you can do following if your cArrayList is ArrayList

String[] colors = new String[cArrayList.size()] ;
for(int i=0;i<cArrayList.size();i++)
{
  colors[i]=cArrayList.get(i);
}

Alternatively, you can use the more concise and faster approach:

String[] colors = cArrayList.toArray(new String[cArrayList.size()]);
share|improve this answer
1  
@Oreo check updated answer and let me know – Pavan Sep 19 '15 at 6:12
    
thank you bro have a nice day :) – Oreo Sep 19 '15 at 6:25
    
getting NPE at this line checkedColors[which] = isChecked; check this: pastebin.com/81PBd4Rd – Oreo Sep 19 '15 at 6:47
    
where you defining checkedColors i dint see initialization of checkedColors – Pavan Sep 19 '15 at 6:54
    
global boolean[] checkedColors = null; @Pavan check this : pastebin.com/81PBd4Rd – Oreo Sep 19 '15 at 6:54

Like in Core Java you convert int[] to List<Integer> same as the code shows below:

    int[] ints = {100,1000,10000};
    List<Integer> ls = new ArrayList<Integer>();
    for (int index = 0; index < ints.length; index++)
    {
        ls.add(ints[index]);
    }

View reference How to convert int[] into List in Java?

share|improve this answer

To convert your integer value to a string use:

String.valueOf(insert your integer value here);
share|improve this answer
    
It convert your integer value to string – akhil batlawala Sep 19 '15 at 5:28

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.