Tabbed dialog with fragments in widget
Asked Answered
M

2

7

I am working on widget, where for widget settings i am looking to provide a dialog for with tab fragment, the problem is dialog do not have action bar tabs, i have tried various lay out patterns, but none of them seems to work.

  1. In the manifest, have made the activity

    <activity android:theme="@android:style/Theme.Dialog"  android:launchMode="singleInstance"
              android:name="WidgetConfigureActivity"></activity>
    
  2. I am not sure, which layout to use exactly ViewPager, FragmentTabHost in the UI, basically not clear which layout to go for.

  3. WidgetConfigureActivity extends FragmentActivity for now, the below is the code for it(code is taken from FragmentTabHost)

    FragmentTabHost mTabHost;
    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.widget_configure_activity);
        mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup(this, getSupportFragmentManager(), R.id.tabhost);
        //this above setup line gives error => (The method setup(Context, FragmentManager, int) in the type FragmentTabHost is not applicable for the arguments (WidgetConfigureActivity, FragmentManager, int))
        mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
                MyFragment.class, null);
    }
    

ViewPager is not that important, but how to have tabbed dialog with fragments is the question?

4. How to make UI/layout NOT change even if apply Theme.Dialog to my activity, all the font appear white in white background? (i have seen text by tilting the screen)

Monovalent answered 29/5, 2013 at 6:12 Comment(0)
L
2

I am not sure, which layout to use exactly ViewPager, FragmentTabHost in the UI, basically not clear which layout to go for.

It depends on you needing swipe tabs(so the user can swipe not only click through the tabs) or not. If you do need swipeable tabs(and I recommend that you implement it as it's a nice option for the user) you could use a ViewPager along a TabHost(instead of using a FragmentTabHost). There are a lot of sample out there on how to do this, I've made one myself that you can find here.

How to make UI/layout NOT change even if apply Theme.Dialog to my activity, all the font appear white in white background? (i have seen text by tilting the screen)

You'll need to make your own theme, extending from Theme.Dialog and "fix" the properties you want. Alejandro Colorado has pointed out the solution.

Larsen answered 18/6, 2013 at 8:41 Comment(0)
T
1

A possible answer to your 4th point is adding this to your style (which is based on the standard Theme.Dialog):

<item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item>

Likewise, try this example of FragmentTabHost, although the tabs are at the bottom.

Totipalmate answered 17/6, 2013 at 22:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.