我试图用onCreate方法中的requestWindowFeature((int) Window.FEATURE_NO_TITLE);从Dialog中删除标题,但它不起作用,因为它给出了异常:
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();
}
});我已经在我的代码中的对话框中做到了这一点,从来没有遇到过问题,但我不能解决这个问题,所以任何帮助都是非常感谢的!
提前谢谢你!
发布于 2012-06-19 22:07:46
修复了调用将显示CustomDialog的mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);的问题:
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-19 17:38:35
请检查此代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature((int) Window.FEATURE_NO_TITLE);
setContentView(R.layout.leesmeerdialog_layout);
...
}发布于 2012-06-19 17:40:19
使用此选项隐藏对话框中的标题。
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}https://stackoverflow.com/questions/11098264
复制相似问题