0

Horizo​​ntalFieldManager の Background を設定したいです。私が探していたサンプル コードは、メイン画面の背景にグラデーションを使用して背景を設定しています。

 //create gradient linear for background
 this.getMainManager().setBackground(BackgroundFactory.createLinearGradientBackground(0x0099CCFF,
                            0x0099CCFF,0x00336699,0x00336699)
                        );

次に、このメソッドがあるため、同じパターンを使用して背景を Horizo​​ntalFieldManager に設定しようとします。しかし、それはうまくいきません。これがコードです

            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);

Horizo​​ntalFieldManager を使用して 4 つの BitmapField を追加し、BackgroundFactory を使用して solidBackground を作成し、マネージャーに設定しましたが、実行すると背景色が適用されません。グラデーションの例はうまく機能します。不足しているものはありますか?私を助けてください。

ありがとう

4

1 に答える 1

4

ディープウェブ検索を行った後。これが答えです

HorizontalFieldManager manager = new HorizontalFieldManager()
{
    public void paint(Graphics graphics)
    {
        graphics.setBackgroundColor(0x000000FF);//blue
        graphics.clear();
        super.paint(graphics);
    }
};

更新: 0x006699FF などの Web Color のみを使用する必要がありますが、0x00606A85 は機能しません。特定の色が必要な場合は、ビットマップを使用することをお勧めします。

更新: 別の解決策

 HorizontalFieldManager manager = new HorizontalFieldManager(Field.USE_ALL_WIDTH);
 manager.setBackground(BackgroundFactory.BackgroundFactory
            .createSolidBackground(0x00cccccc));
于 2011-05-13T14:43:49.603 に答える