I am populating JSON parsed data into Dialog, like this:
String[] colors = new String[] {cArrayList.toString()};
Log.d("colors::-", Arrays.toString(colors));
GETTING
EXPECTED
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()]);
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?
To convert your integer value to a string use:
String.valueOf(insert your integer value here);
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?