Fredkr
Fredkr

Reputation: 723

Issue with dialog box and Theme.Dialog theme Android

Having a minor problem, I'm trying to create an "about us" dialog box by using MenuInflater and Theme.Dialog . i want this to show on top of the currently running layout.

But when i run it it basically shuts the program down and the dialog box appears as a new window.[Printscrren]: https://i.sstatic.net/JQcpm.jpg Hopefully someone understands what i mean.

public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch(item.getItemId()){
    case R.id.aboutUs:

        Intent i = new Intent("fredkr.memrly.ABOUT");
        startActivity(i);
        break;
    case R.id.gameDetails:

        break;
    }
    return false;
}

//

         <activity
        android:name=".AboutUs"
        android:theme="@android:style/Theme.Dialog"

         >
        <intent-filter>
            <action android:name="fredkr.memrly.ABOUT" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Upvotes: 0

Views: 549

Answers (1)

Benoir
Benoir

Reputation: 1244

I think you want

dialog = new Dialog(this,android.R.style.Theme_Dialog); // or whatever the theme is
dialog.setContentView(R.layout.dialog); // the xml for the dialog
dialog.show();

you're starting it as a new activity right now, which takes the place of the current one -- doing it this way will keep the original activity

Upvotes: 1

Related Questions