gpt4 book ai didi

java - 每 3 秒更新一次 textView 值

转载 作者:行者123 更新时间:2023-12-01 19:22:21 24 4
gpt4 key购买 nike

我正在使用 listItems 数组,其中包含复选框,每个选中的项目都保存在 mUserItems 数组中我想打印在 mItemSeleced 中分隔的每个选中项目> 使用倒计时器将 textView 保留 3 秒,然后将其删除并获取其他项目 3 秒,依此类推;问题是 3 秒后我只检查了最后一项

public void onClick(DialogInterface dialogInterface, int which) {
for (int i = 0; i < mUserItems.size(); i++) {
final int j = i;
new CountDownTimer(3000, 1000) {
public void onTick(long millisUntilFinished) {}
public void onFinish() {
mItemSelected.setText("");
mItemSelected.setText(listItems[mUserItems.get(j)]);
}
}.start();
}
}

最佳答案

如果您使用循环或递归,请尝试使用

延迟(3000);在更新语句之后(然后循环继续)!

关于java - 每 3 秒更新一次 textView 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59344938/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com