title: Android change menu item Text color dynamically
body: <p>I am trying to change menu item text color dynamically.</p>
  
  <p>I have a solution that works for menu icons, it uses the color filter as follows:  </p>
  
  <pre><code>Drawable drawable = menuItem.getIcon();
  
          if (drawable != null) {
              drawable.mutate();
              drawable.setColorFilter(new
                      PorterDuffColorFilter(Color.parseColor(color), PorterDuff.Mode.MULTIPLY));
          }
          menuItem.setIcon(drawable);
  </code></pre>
  
  <p>Output:<a href="https://i.stack.imgur.com/dNR8h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dNR8h.png" alt="enter image description here"></a></p>
  
  <p>I am unable to change the color of menu item text. To make this work I used the following code:</p>
  
  <pre><code> SpannableString s = new SpannableString(menuItem.getTitle());
                  s.setSpan(new ForegroundColorSpan(Color.parseColor(color)), 0, s.length(), 0);
                  menuItem.setTitle(s);
  </code></pre>
  
  <p>Output:<a href="https://i.stack.imgur.com/3OeSe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3OeSe.png" alt="enter image description here"></a></p>
  
  <p>the color of "SAVE" is what I am trying to change.</p>
  
  <p>Can anyone help me out with this?</p>