Android:处理对话框在不同字符串之间循环
我想知道,当我有一个进程对话框线程弹出窗口时,文本是否能够循环通过一系列不同的字符串。有点像旧的模拟城市游戏,当你创建一个新的城市时,它会说: 建筑物 TeraForming 填充 等等 哈哈,这不是最好的例子,但这是我想到的第一件事。我将其用于基本对话框:Android:处理对话框在不同字符串之间循环,android,process,Android,Process,我想知道,当我有一个进程对话框线程弹出窗口时,文本是否能够循环通过一系列不同的字符串。有点像旧的模拟城市游戏,当你创建一个新的城市时,它会说: 建筑物 TeraForming 填充 等等 哈哈,这不是最好的例子,但这是我想到的第一件事。我将其用于基本对话框: private class LoadingThread extends AsyncTask<Void, Void, String> { @Override protected String doInBac
private class LoadingThread extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... params) {
try {
Thread.sleep(8000);
}
@Override
protected void onPostExecute(String result) {
progressDialog.dismiss();
new AlertDialog.Builder(MyClass.this)
.setMessage(result).setCancelable(false).setTitle("Title")
.setPositiveButton("Done", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Sorry.", Toast.LENGTH_LONG).show();
}
}
).show();
}
}
我建议不要使用计时器,因为加载时间从来都不是恒定的。相反,根据正在加载的内容,使用进度百分比更改标题或文本
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.progressDialog =
ProgressDialog.show(
this,
"String 1",
"String 2"
);
new LoadingThread().execute();
}