我想设置HorizontalFieldManager的背景。我一直在搜索的示例代码是使用渐变为主屏幕背景设置背景。
//create gradient linear for background
this.getMainManager().setBackground(BackgroundFactory.createLinearGradientBackground(0x0099CCFF,
0x0099CCFF,0x00336699,0x00336699)
);然后,我尝试使用相同的模式将背景设置为HorizontalFieldManager,因为它具有此方法。但它不会起作用。下面是代码
HorizontalFieldManager hManager = new HorizontalFieldManager();
Bitmap bitmapImage = null;
bitmapImage = Bitmap.getBitmapResource("img/home.png");
tabHome = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
| BitmapField.HIGHLIGHT_FOCUS);
bitmapImage = Bitmap.getBitmapResource("img/in.png");
tabCheckInOut = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
| BitmapField.HIGHLIGHT_FOCUS);
bitmapImage = Bitmap.getBitmapResource("img/barcode.png");
tabBarcode = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
| BitmapField.HIGHLIGHT_FOCUS);
bitmapImage = Bitmap.getBitmapResource("img/options.png");
tabOptions = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
| BitmapField.HIGHLIGHT_FOCUS);
tabHome.setFocusListener(this);
tabCheckInOut.setFocusListener(this);
tabBarcode.setFocusListener(this);
tabOptions.setFocusListener(this);
Background topBack = BackgroundFactory.createSolidBackground(0x00606A85);
hManager.setBackground(topBack);
hManager.add(tabHome);
hManager.add(tabCheckInOut);
hManager.add(tabBarcode);
hManager.add(tabOptions);
add(hManager);我使用HorizontalFieldManager并添加4个BitmapField,然后使用BackgroundFactory创建solidBackground,并将其设置为管理器,但当我运行它时,背景颜色不适用。渐变示例运行良好。我是不是漏掉了什么?请帮帮我。
谢谢
发布于 2011-05-13 22:43:50
在做了一些深度网络搜索之后。这是答案,伙计们
HorizontalFieldManager manager = new HorizontalFieldManager()
{
public void paint(Graphics graphics)
{
graphics.setBackgroundColor(0x000000FF);//blue
graphics.clear();
super.paint(graphics);
}
};更新:您必须只使用网页颜色,如0x006699FF应该可以工作,但0x00606A85将不能工作。如果你想要一种特定的颜色,我建议你使用位图。
更新:另一个解决方案
HorizontalFieldManager manager = new HorizontalFieldManager(Field.USE_ALL_WIDTH);
manager.setBackground(BackgroundFactory.BackgroundFactory
.createSolidBackground(0x00cccccc));https://stackoverflow.com/questions/5980366
复制相似问题