title: How to set actionBar in fragment on Xamarin Android?
body: <p>I am trying to change the color and image icon on an <code>actionBar</code></p>
  
  <p>I have tried to use <code>OnAttach</code> but it is not working.</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>You manipulate action bar only from activity. You can do that in fragment in OnAttach method to make sure you have the reference to the activity.</p>
  
  <pre><code>public override void OnAttach(Activity activity)
  {
      base.OnAttach(activity);
      var colorDrawable = new ColorDrawable(Color.White);
      activity.ActionBar.SetBackgroundDrawable(colorDrawable);
  
      var titleId = activity.Resources.GetIdentifier("action_bar_title", "id", "android");
      var abTitle = activity.FindViewById&lt;TextView&gt;(titleId);
      abTitle.SetTextColor(Color.Black);
  }
  </code></pre>