1

我创建了一个警报对话框弹出窗口,允许人们更改我正在制作的游戏的难度。

不幸的是,当我单击ok 、 cancel或在对话框之外时,会显示背景标题窗口,而不是返回主屏幕。

我必须单击额外的时间才能删除背景标题窗口。

如何完全删除它,以便当用户完成更改难度时,他们会直接返回菜单而不是标题窗口?

我尝试使用

requestWindowFeature(Window.FEATURE_NO_TITLE);

但它不会移除盒子。

这是重要的代码:

爪哇:

public class Difficulty extends Activity{

final CharSequence[] items = {"Easy", "Medium", "Hard"};
int daf;
AlertDialog diffMode;
String diff = "DifficultyMode";
String howHard;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    SharedPreferences settings = getSharedPreferences(diff,0);      
    daf = settings.getInt("num",0);     
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Difficulty");
    builder.setSingleChoiceItems(items, daf, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {


        switch(item)
        {
            case 0:
                daf = 0;
                howHard = "Easy";
                     break;
            case 1:
                daf = 1;
                howHard = "Medium";

                    break;
            case 2:
                daf = 2;
                howHard = "Hard";
                    break;

        }
          }
    });

    builder.setPositiveButton("ok", new DialogInterface.OnClickListener(){
        @Override
        public void onClick(DialogInterface dialog, int id){
            SharedPreferences setting = getSharedPreferences(diff,0);
            SharedPreferences.Editor editor = setting.edit();
            editor.putString("mode", howHard);
            editor.putInt("num", daf);
            editor.commit();
            diffMode.dismiss();    
        }
    });

    builder.setNegativeButton("cancel", new DialogInterface.OnClickListener(){
        @Override
        public void onClick(DialogInterface dialog, int id){
            diffMode.dismiss();    
        }
    });
    diffMode = builder.create();
    diffMode.show();
}
}

显现:

<activity
        android:name=".Difficulty"
        android:label="@string/app_name"             
       android:theme = "@android:style/Theme.Dialog"
      >
        <intent-filter>
            <action android:name="com.tnalcove.blindpick.DIFFICULTY" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity> 

我不能发布图片,所以这里是专辑的链接 http://imgur.com/a/IUJJW

4

0 回答 0