teekib
teekib

Reputation: 2821

Android: requestWindowFeature error in Dialog and onResume() method

Hi I searched SO for this kind of error but could not find the solution why this requestFeature() error is triggering while creating custom dialog in onResume() method.

I am calling the dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); before setting the contentview like this dialog.setContentView(R.layout.fav_info_dialog);

Below is my code

@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();
}

Upvotes: 1

Views: 444

Answers (1)

duggu
duggu

Reputation: 38429

Try below code:-

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

Upvotes: 2

Related Questions