gpt4 book ai didi

Android:Dialog 和 onResume() 方法中的 requestWindowFeature 错误

转载 作者:行者123 更新时间:2023-11-29 20:56:06 25 4
gpt4 key购买 nike

您好,我在 SO 中搜索了此类错误,但找不到在 onResume() 方法中创建自定义对话框时触发此 requestFeature() 错误的解决方案。

我调用 dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 在像这样设置内容 View 之前 dialog.setContentView(R.layout.fav_info_dialog);

下面是我的代码

@Override
protected void onResume() {
super.onResume();

supportInvalidateOptionsMenu();
ActivityCompat.invalidateOptionsMenu(Converter.this);
// update the title
updateTheTittle(getResources().getString(R.string.menu_units));
cancleBtn.setVisibility(View.GONE);
//
if (mSharedPref.getInt(Constants.HOME_INFO_DIALOG_STATUS, 0) == 0)
if (mSharedPref.getInt(Constants.DASHOBOARD_TYPE,
Constants.GridView) == 2)
createCustomDialog();
}

private void createCustomDialog() {

final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.fav_info_dialog);

dialog.setCanceledOnTouchOutside(true);

Button button = (Button) dialog.findViewById(R.id.desc_ok);
button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
SharedPreferences mSharedPref = getSharedPreferences(
Constants.PREFERENCE_FILENAME, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = mSharedPref.edit();
editor.putInt(Constants.HOME_INFO_DIALOG_STATUS, 1);
editor.commit();
dialog.dismiss();
}
});
dialog.show();
}

最佳答案

试试下面的代码:-

final Dialog dialog = new Dialog(this,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.myxml);

关于Android:Dialog 和 onResume() 方法中的 requestWindowFeature 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27716826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com