How to display arrays using toast

I want to display an array of numbers using the Toast function. But it only accepts strings. Is there any way to get rid of this problem?

+3
source share
3 answers

To answer @Daniel's question in more detail:

int[] myArray = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
StringBuilder builder = new StringBuilder();
for(int i : myArray)
{
     builder.append("" + i + " ");
}
Toast.makeText(this, builder, Toast.LENGTH_LONG).show();
+4
source

You can use the class StringBuilderto create the desired string from the array.

+4
source

This can be done simply:

Toast.makeText(getApplicationContext(), Arrays.toString(nameSend), Toast.LENGTH_LONG).show();
0
source

All Articles