所以我得到了我正在循环的这个字符串数组。一个菜鸟问题,但是,我如何反转和循环回来?基本上我想要的是“前进”和“后退”功能,因此不必循环整个数组即可返回“a”。谢谢!
public class FirstActivity extends Activity {
private static int counter = 0;
private TextView exampleTextView;
string exampleText;
private static final String[] EXAMPLESTRINGS = {
"a",
"b",
"c"
};
public void generateText(View v) {
String exampleText = EXAMPLESTRINGS[counter++];
if( counter == EXAMPLESTRINGS.length ) {
counter = 0;
}
exampleTextView.setText(exampleText);
}