我的 Android 应用程序中有一个活动类,在处理了一些数据后,该数据被发送到另一个类中的另一个方法,该方法返回一个 ArrayList。我想要做的是遍历该 ArrayList 并且对于其中的每一段文本,我想更新我界面中的 TextView 标签。但是,只要用户按下屏幕上的“是”按钮,就应该这样做。(即,每当用户按下“是”按钮时,循环将前进到 ArrayList 的下一个元素,并在 TextView 标签中更新其值)。这是我到目前为止所拥有的:
try {
sentenceGenerator = new SentenceGenerator();
ArrayList<ArrayList<String>> states = stateGenerator
.getPossibleStates(resultOutput, result, result);
for (ArrayList<String> state : states) {
viewPoint = state.get(0);
subject = state.get(1);
object = state.get(2);
subjectInfo = new ObjectReference();
if (resultOutput.equals("Sliema")) {
Sliema sliema = new Sliema();
subjectInfo = sliema.getInfo(viewPoint, object, subject);
}
try {
s = sentenceGenerator.generateSentence("start", "middle",
"end", resultOutput, viewPoint, object, subject,
subjectInfo.type, subjectInfo.name,
subjectInfo.properties, false);
instructionTextView = (TextView) findViewById(R.id.instructionTextView);
mHandler = new Handler();
instructionTextView
.setText("Press 'Yes' to start Orientation procedure");
Button confirmButton = (Button) findViewById(R.id.confirmButton);
Button declineButton = (Button) findViewById(R.id.declineButton);
confirmButton
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mHandler.post(mUpdate);
}
});
declineButton
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//
}
});
Log.d("INSTRUCTIONS", s);
} catch (Exception e) {
}
}
} catch (ClassNotFoundException e) {
}
这是更新处理程序:
private Runnable mUpdate = new Runnable() {
public void run() {
instructionTextView.setText(s);
// mHandler.postDelayed(this, 1000);
confirmPressed = true;
// i++;
}
};
有什么建议么?提前致谢!