When I add a second activity for android target, it has not TitleBar

RudolfVonKrugsteinRudolfVonKrugstein DEMember ✭✭
edited November 6 in Xamarin.Forms

Hey,

Because I want to create a native Android Preference screen in my xamarin forms app, I added a second Activity:

    [Activity(Label = "Unicat OM Settings", Icon = "@drawable/icon", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class SettingsActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.ActionBar);
            this.Title = "Title";
            base.OnCreate(bundle);

            // Display the fragment as the main content.
            PrefsFragment prefsFragment = new PrefsFragment();
            this.FragmentManager.BeginTransaction().Replace(global::Android.Resource.Id.Content, prefsFragment).Commit();
        }
    }

The theme @style/MainTheme is set to:

 <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
...

Unfortunately, the activity does not have a Titlebar. As you can see in the code, I tried to add the Titlebar via RequestWindowFeature, but no luck.

How can I add the titlebar?

I just realize, I kind of double post with here: https://forums.xamarin.com/discussion/106180/adding-a-actionbar-to-a-preferenceactivity#latest
Sorry for that.

Sign In or Register to comment.