I cannot manage to display each item of a String in a Java/Android app. Here is my code :
int i;
Button changer;
private EditText changerlettres;
String choix;
@SuppressLint("ClickableViewAccessibility")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
changerlettres = (EditText)findViewById(R.id.changerlettres);
changer = (Button)this.findViewById(R.id.changer);
BtnClick();
}
public void BtnClick() {
changer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
choix = changerlettres.getText().toString();
for (int i = 0, n = choix.length(); i < n; i++) {
char letter = choix.charAt(i);
System.out.println(letter); //Does not display anything
Toast.makeText(MainActivity.this,choix,Toast.LENGTH_SHORT).show();// Displays correctly
Toast.makeText(MainActivity.this,letter,Toast.LENGTH_SHORT).show(); // Crash of the app
What should be the best way to display the string items one by one ? Many thanks for your help