2011-04-20 98 views

回答

0

您必須嘗試使用​​菜單文字更改菜單顏色的代碼。

private void setMenuBackground() { 
    // TODO Auto-generated method stub 
    getLayoutInflater().setFactory(new Factory() { 
      @Override 
      public View onCreateView (String name, Context context, AttributeSet attrs) { 
       if (name.equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) { 
       try { 

         LayoutInflater f = getLayoutInflater(); 
         final View view = f.createView(name, null, attrs); 

         new Handler().post(new Runnable() { 
          public void run() { 
           view.setBackgroundColor(Color.GRAY); 
          } 
         }); 
         return view; 
        } 
        catch (InflateException e) { 
        } 
        catch (ClassNotFoundException e) { 
        } 
       } 
       return null; 
      } 
     }); 
} 
相關問題