Search code examples
xamarin.android

Change ToolBar Title dynamically on click events in Fragment on Xamarin android?


First let me explain something, so you guys can understand better my problem:

I'm using Toolbar and i have a Fragment called Location Fragment where i have 6 floationg action button vertically . When you click on one of the floating action button some action like geofence,live tracking,current location etc are performed on the same map fragment.

So my problem is that when i click any of the floation action button ,like when i click geo-fencing floation action button the title on the tool bar should change with the geofence title..In this way for all the Floating action button the title of toolbar should change. in my case the title of the tool bar is not changing .

I have tried to use setTitle or this.Activity.Title="Geo-fence" on the click method of Floating action button,but still it remains same title .


Solution

  • Change ToolBar Title dynamically on click events in Fragment

    In your Fragment, add the following code in your click events :

    ((AppCompatActivity)Activity).SupportActionBar.SetTitle(Resource.String.YourTitle);