title: Set custom font for menu items in Android
body: <p>I tried to implement a custom menu. I used the answer given in <a href="https://stackoverflow.com/questions/4135699/how-to-set-a-font-for-the-options-menu">this</a> question. In my code the name is ExpandedMenuItem, but in all the examples it is IconMenuItemView. What is happening there? How can I correct this?</p>
  
  <p>Here is my code.</p>
  
  <pre><code>    public class MyActivity extends PreferenceActivity {
  
           @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.proximity_alert_menu, menu);
      getLayoutInflater().setFactory(new Factory() {
  
          @Override
          public View onCreateView(String name, Context context, AttributeSet attrs) {         
  
                          //if(name.equalsIgnoreCase("com.android.internal.view.menu.MenuItem")) {}
                          try {
                             LayoutInflater li = LayoutInflater.from(context);
                             final View view = li.createView(name, null, attrs);
                             new Handler().post(new Runnable() {
                             public void run() {
                              TextView tView = (TextView) view;
                              tView.setTypeface(Config.set_font);
                              tView.setTextColor(Color.RED);
                             }
                      });
                      return view;
                   } catch (InflateException e) {
                     e.printStackTrace();
                   } catch (ClassNotFoundException e) {
                     e.printStackTrace();
                   }
                   return null;
        }
          });
      return super.onCreateOptionsMenu(menu);
          }
      }
  </code></pre>
  
  <p>Exception show that</p>
  
  <pre><code>      java.lang.ClassCastException:com.android.internal.view.menu.ExpandedMenuView cannot be cast to android.widget.TextView
  </code></pre>
  
  <p>How can i cast this into TextView?</p>