【发布时间】:2016-08-26 17:00:36
【问题描述】:
我想显示 AsyncTask 中其他类中的 AlertDialog。 示例>
public class WardListAsyncTask extends AsyncTask<HashMap<String, String>, String, Object> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Object doInBackground(HashMap<String, String>... params) {
...
}
@Override
protected void onPostExecute(Object result) {
ConfirmAlertDialog(ez_WardList.this,"HI?");
//this method is in another Class & I want to use this method another Asynctask also..
}
并且 ConfirmAlertDialog 是...
Context g_ctx;
String g_content;
public void ez_ConfirmAlertDialog(Context ctx, String content) {
this.g_ctx=ctx;
this.g_content=content;
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(g_ctx, AlertDialog.THEME_HOLO_LIGHT);
builder.setMessage(g_content).setPositiveButton(getString(R.string.kor_confirm),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
alertDialog.getWindow().setLayout(displayWidth / 2, LayoutParams.WRAP_CONTENT);
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.rgb(10, 174, 239));
}
});
}
我认为 g_ctx.class.runonuiThread ...但我不能调用 runonuithread ...
我该如何解决?
【问题讨论】:
-
致电
#Context.runonuithread。
标签: android android-asynctask android-alertdialog