R.Extrant
R.Extrant

Reputation: 181

CustomView in ActionBar disappear when orientation change ? (AppCompat)

Problem :

I personalized my actionBar (SupportActionBar) with a renderer on my CustomNavigationPage beacause I use AppCompat theme. So, I added my CustomView (a SearchBar) in the actionbar from this class.

But ... when we change the orientation (Portrait->Landscape / Landscape->Portrait) my view disappear and I must recreate my CustomNavigationPage if I want to see again my CustomView.

I need your help, thank you in advance !

Upvotes: 0

Views: 290

Answers (1)

R.Extrant
R.Extrant

Reputation: 181

Finally, I solved this problem by the id of the toolbar :

        int toolbarId = Resources.GetIdentifier("toolbar", "id", Android.App.Application.Context.PackageName);
        Android.Support.V7.Widget.Toolbar actionBar = (Android.Support.V7.Widget.Toolbar)FindViewById(toolbarId);

When we use AppCompat, it's the toolbar which is used. Then, I remove views and add again my CustomView.

Upvotes: 0

Related Questions