2012-03-16 92 views
1

我在我的應用程序中創建了custom menu,我已經在菜單中設置了其項目顯示的background,border and font。但是我無法爲菜單中的菜單項顯示設置font color
如何設置字體顏色爲菜單項?? ..
我的代碼看起來是這樣的:
我已經設置邊框,背景和字體,如下圖所示: -黑莓中的自定義菜單 - 更改菜單項的字體顏色

XYEdges edge = new XYEdges(10, 10, 10, 10); 
menu_border = BorderFactory.createRoundedBorder(edge,Border.STYLE_DOTTED); 
menu_back = BackgroundFactory.createSolidTransparentBackground(Color.LIGHTPINK,50); 
    try 
    { 
     FontFamily fnt_family = FontFamily.forName("BBCasual"); 
     menu_font = fnt_family.getFont(Font.PLAIN,30,Ui.UNITS_px); 
    } 
    catch(ClassNotFoundException e){ 
    } 

和我重寫列出MakeMenu如圖所示()函數:

protected void makeMenu(Menu menu,int context) 
{ 
    menu.setBackground(menu_back); 
    menu.setBorder(menu_border); 
    menu.setFont(menu_font); 
    super.makeMenu(menu, context); 
} 

在此先感謝..

回答

3

有沒有API來完成你想要的。

+0

是否有任何其他方式做到這一點? – 2012-03-16 11:34:25

+2

我不這麼認爲。 – 2012-03-16 12:24:05

-1
LabelField label0=new LabelField(" Label",LabelField.USE_ALL_WIDTH){ 

    public void paint(Graphics g) 
    {         
      g.setColor(Color.RED); 
      super.paint(g); 
    } 
}; 

此代碼設置的labelField紅色使用它的菜單字體顏色和改變顏色爲u想

+0

此代碼既不能用於'Menu'也不能用於'MenuItem'。 – mrvincenzo 2012-03-16 13:31:33