-5
我想要一个接一个地从String
数组返回单词。我怎样才能从一个字符串数组使用返回语句的所有单词
public String CurrentString(int move) {
int currentString = 0;
EditText ed = (EditText) findViewById(R.id.ed);
String[] strings = ed.getText().toString().split(" ");
int newString = currentString move;
if (newString >= strings.length) {
// if the new position is past the end of the array, go back to the beginning
newString = 0;
}
if (newString < 0) {
// if the new position is before the beginning, loop to the end
newString = strings.length - 1;
}
currentString = newString;
Toast.makeText(getApplicationContext(), strings[currentString],Toast.LENGTH_LONG).show();
return strings[currentString];
}
问题是我的上面的代码没有返回所有的文本。请帮忙。
这是真的很难理解你的问题,因为代码是另一回事,请修复它也有在你的代码的一些bug ** currentString;!** ?? –
考虑看的StringTokenizer – JoxTraex
“没有按不会返回所有文本“...嗯,是的,你从数组中返回一个元素 –