2012-03-16 88 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