I'm studying Java, and Android development, and I want to make this application to understand how it works.
I'm using the Toast class so that when I click on the image, a phrase appears, I managed to make it work with numbers, but instead of the numbers I want to put some sentences and when I click on the image, the phrase appears for a few seconds in the screen.
How do I do this without too many changes to this code I already have?
package android.tutorial.android;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
// public void mostrarMensagem(View view) {
//Toast toast = Toast.makeText(this.sorteia(), Toast.LENGTH_SHORT);
//toast.show();
//}
public void mostrarMensagem(View view) {
int[] lista = new int[]
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
};
StringBuilder builder = new StringBuilder();
for(int i : lista)
{
builder.append("" + i + " ");
}
Toast.makeText(this, builder, Toast.LENGTH_LONG).show();
}
}