本文介绍了Andengine要求与面包的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我不知道是否有用于andengine或ADK要问的问题,碰杯任何原生支持?例如,如果我preSS后退按钮,我想要一些框弹出,询问我是否真的要退出应用程序,并给我肯定的回答选项或没有。

I wonder if there is any native support for andengine or ADK to ask question-toasts? For example if I press the back button, I want some box to popup asking if I really want to quit the application and give me the option to answer yes or no.

推荐答案

最好使用警告对话框使用这种code,希望同样的工作一样,

Better to use alert dialog use this code, hope work same like that

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub

    switch(keyCode)
    {
    case KeyEvent.KEYCODE_BACK:
        AlertDialog.Builder ab = new AlertDialog.Builder(AlertDialogExampleActivity.this);
        ab.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
        .setNegativeButton("No", dialogClickListener).show();
        break;
    }

    return super.onKeyDown(keyCode, event);
}

DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        switch (which){
        case DialogInterface.BUTTON_POSITIVE:
            //Yes button clicked
            break;

        case DialogInterface.BUTTON_NEGATIVE:
            //No button clicked
            break;
        }
    }
}

这篇关于Andengine要求与面包的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:54