I want to insert a for statement that increments and displays Strings on a TextView when the user clicks the Next button. But when i press the button it displays “3”. Can anyone point out where im going wrong. Thanx
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.one:
break;
case R.id.Next:
final CharSequence[] items = {"Test", "Test1", "Test3", "Test4"};
for(i=0; i<items.length; i++){
String s = (String)items[i];
info.setText(s);
}
break;
}
}
Your
forloop loops until the last value each time you click theButton. If you just want to show the next string: