error java.lang.RuntimeException: Can't create handler inside
thread that has not called Looper.prepare() =(
如果我打电话-showDialog (id)
工作GameActivity
但如果我activity.showDialog
从另一个班级打电话 - 一个错误
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 1:
Log.d("Dialog", "Dialog 1");
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Help");
alert.setMessage("Help");
WebView wv = new WebView(this);
wv.loadUrl("http:\\www.google.com");
wv.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
alert.setView(wv);
AlertDialog ALERT = alert.create();
return ALERT;
default:
return null;
}
}
我想与任何其他班级进行对话
更新:
new code activiti.runOnUiUpdate()
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 1:
this.runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d("Dialog", "Dialog 1");
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Help");
alert.setMessage("Help");
WebView wv = new WebView(this);
wv.loadUrl("http:\\www.google.com");
wv.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
alert.setView(wv);
AlertDialog aALERT = alert.create();
}
});
return ALERT;
default:
return null;
}
}