0

我试图从方法中的DialogwithrequestWindowFeature((int) Window.FEATURE_NO_TITLE);中删除标题onCreate,但它不起作用,因为它给出了异常:

06-19 09:35:00.319: E/AndroidRuntime(5071): android.util.AndroidRuntimeException: requestFeature() must be called before adding content

我有requestWindowFeature((int) Window.FEATURE_NO_TITLE);之前的内容,如下所示:

@Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature((int) Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.leesmeerdialog_layout);
        ...
}

我也尝试过,但仍然没有运气

@Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
            requestWindowFeature((int) Window.FEATURE_NO_TITLE);
            setContentView(R.layout.leesmeerdialog_layout);
            ...
    }

使用show()方法调用对话框时会弹出异常:

mLeesMeer.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mDialog = new LeesMeerDialog(getActivity(), mDescription, new OnReadyListener());
                mDialog.show();
            }
        });

我已经在我的代码中的对话框中做到了这一点,从来没有遇到过问题,但我无法弄清楚这个问题,所以非常感谢任何帮助!

提前非常感谢!

4

4 回答 4

0

请检查此代码:

@Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        requestWindowFeature((int) Window.FEATURE_NO_TITLE);
        setContentView(R.layout.leesmeerdialog_layout);
        ...
}
于 2012-06-19T09:38:35.100 回答
0

使用它来隐藏对话框中的标题。

    public void onCreate(Bundle savedInstanceState) {

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    }
于 2012-06-19T09:40:18.737 回答
0

可能是因为你在打电话

mDialog.setContentView(R.layout.customdialog_layout);

当您尝试显示对话框时调用mDialog.show();
TheonCreate

于 2012-06-19T09:44:45.847 回答
0

修复了它调用mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);CustomDialog要显示的位置:

mDialog = new CustomDialog(getActivity(), getResources().getString(R.string.ervaringen_post_msg), new OnReadyListener());
                mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                mDialog.setContentView(R.layout.customdialog_layout);
                mDialog.show();
于 2012-06-19T14:07:45.777 回答