Issue
I have an pop-up dialog, that need to display at the start up of an activity. To start the popup at start up, I have placed it on onStart(). That works fine, but it displaying the blank title on the pop-up dialog. To Removed this, I have tried with dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
But this getting and runtime exception. below is the OnStart() method:
@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();
}
Exception: android.util.AndroidRuntimeException: requestFeature must be called before adding to the content.
Please help me on this.
Thanks' in advance.
Solution
Try this property of dialog
final Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
Remove this
dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
UPDATE
try this style
final Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
Update 2:
Add below style to the style.xml and use it on dialog declaration
<style name="NoTitleDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
This is correctly acceptable as it extends android's Theme.Dialog style.
Answered By - Biraj Zalavadia
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.