我有一个弹出对话框,需要在活动启动时显示。要在启动时启动弹出窗口,我将它放在onStart()上。这工作正常,但它在弹出对话框上显示空白标题。要删除这个,我已经尝试过dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
但是这个获取和运行时异常。下面是 OnStart() 方法:
@Override
protected void onStart()
{
super.onStart();
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.popup_layout);
dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
Button mYes = (Button) dialog.findViewById(R.id.button1);
Button mNo = (Button) dialog.findViewById(R.id.button2);
mYes.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "msg1", Toast.LENGTH_LONG).show();
finish();
}
});
mMoveToWallet.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "msg2", Toast.LENGTH_LONG).show();
dialog.cancel();
}
});
dialog.show();
}
例外: android.util.AndroidRuntimeException: requestFeature must be called before adding to the content.
请帮助我。提前致谢。