Friday, August 31, 2012

[android-developers] Re: How to attach actionbar on dialog?

Hello, yes, I found a "solution":

I used a activity instead...

<style name="PopupTheme" parent="android:Theme.Holo.Light.Dialog">
        <item name="android:windowIsFloating">false</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowSoftInputMode">stateAlwaysHidden</item>
        <item name="android:windowActionModeOverlay">true</item>
        <item name="android:windowIsTranslucent">true</item>
    </style>

public static void showAsPopup(Activity activity) {
        //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
        activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
        activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
                WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        LayoutParams params = activity.getWindow().getAttributes();
        params.height = LayoutParams.FILL_PARENT;
        params.width = 850; //fixed width
        params.alpha = 1.0f;
        params.dimAmount = 0.5f;
        activity.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    }

Good luck!

2012/8/31 Christophe Versieux <christophe.versieux@gmail.com>
Did you find an answer? I have the same question...


On Wednesday, September 21, 2011 9:11:28 PM UTC+2, Igor Oliveira wrote:
Hello, I would like to know how to implement a screen like the EditEventActivity from Android Calendar on Android 3.1.

See picture below:

http://imageshack.us/photo/my-images/269/sc20110921105601.jpg/

I've created a dialog and I'm trying to put a actionbar on the dialog via onCreateOptionsMenu(), but the action bar doesn't appear.

I'm using <uses-sdk android:minSdkVersion="12" android:targetSdkVersion="12"/> and the Theme.Holo.Light.Dialog on the dialog.

When I call getActionBar() I always get null.

From documentation:
"ActionBar     getActionBar()
Retrieve the ActionBar attached to this dialog, if present."

So how can I attach a dialog on a dialog? Can you help me?

Thanks in advance.

--
Igor Oliveira




--
Igor Oliveira

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment