如何创建与andengine警告对话框 [英] How to create alert dialog with andengine
本文介绍了如何创建与andengine警告对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用andengine游戏开发
现在我需要的是建立一个警报对话框
我用这
I am developing game using andengine now i need is to create a alert dialog box i am using this
case MENU_OPT:
mEngine.runOnUpdateThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder alert = new AlertDialog.Builder(GameActivity.this);
alert.setTitle("");
alert.setMessage("");
alert.setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
});
alert.show();
}
});
break;
但得到的错误
了java.lang.RuntimeException:无法内螺纹创建的处理程序已经不叫尺蠖prepare()
but getting error java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
什么是code中的问题,或者我可以使用alertdialog建设者andengine与否。
what is the problem with code or can i use alertdialog builder with andengine or not.
推荐答案
只要对象主要活动类和使用对象
Just make the Object Of Main Activity class and use the Object
activity.runOnUIThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder alert = new AlertDialog.Builder(GameActivity.this);
alert.setTitle("");
alert.setMessage("");
alert.setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
});
alert.show();
}
});
这篇关于如何创建与andengine警告对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文