добавление изображения / значка внизу экрана - PullRequest
0 голосов
/ 18 марта 2012

Я хочу отобразить 4 кликабельных изображения / иконки внизу экрана в ежевике, я не могу найти образец приложения для этого.

Я пробовал это, но я не могу показать это изображение внизу и сделать его кликабельным

package com.samples.backgroundImage;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

public class NativeUI extends UiApplication
{
    private Bitmap backgroundBitmap;
    private Bitmap fieldBitmap;

    public static void main(String[] args)
    {
            NativeUI theApp = new NativeUI();
            theApp.enterEventDispatcher();
    }

    public NativeUI()
    {
        //The background image.
        backgroundBitmap = Bitmap.getBitmapResource("cryptodemo_jde.png");

        MainScreen mainScreen = new MainScreen();

        HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT){

            //Override the paint method to draw the background image.
            public void paint(Graphics graphics)
            {
                //Draw the background image and then call paint.
                graphics.drawBitmap(0, 0, 240, 240, backgroundBitmap, 0, 0);
                super.paint(graphics);
            }            

        };

        //The LabelField will show up through the transparent image.
        LabelField labelField = new LabelField("This is a label");

        //A bitmap field with a transparent image.
        //The background image will show up through the transparent BitMapField image.
        BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("pimdemo_jde.png"));

        //Add the manager to the screen.
        mainScreen.add(horizontalFieldManager);
        BasicEditField bef = new BasicEditField("To: ","",50,BasicEditField.FILTER_EMAIL);
        horizontalFieldManager.add(bef);
        //Add the fields to the manager.
        horizontalFieldManager.add(labelField);
        horizontalFieldManager.add(bitmapField);

        //Push the screen.
        pushScreen(mainScreen);
    }
}

Ответы [ 2 ]

1 голос
/ 18 марта 2012

Я немного изменил ваш код.

Сначала добавлен VerticalFieldManager, который занимает всю высоту дисплея и выравнивает поля по вертикали.VFM содержит все ваши поля, кроме BitmapField.Затем добавили HorizontalFieldManager, который занимает оставшуюся часть доступной высоты дисплея.Наконец, BitmapField добавляется в HFM со стилем FIELD_BOTTOM , который указывает HFM выровнять поле по низу менеджера.

Если вы хотите добавить больше изображений в нижнюю частьна экране, просто создайте их в стиле FIELD_BOTTOM и добавьте их в HFM.

Проверьте этот ответ для получения дополнительной информации о выравнивании полей.

Вот ваш код с вышеупомянутыммодификации

public NativeUI() {
    //The background image.
    backgroundBitmap = Bitmap.getBitmapResource("cryptodemo_jde.png");

    MainScreen mainScreen = new MainScreen(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_HORIZONTAL_SCROLL);

    VerticalFieldManager verticalFieldManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_HORIZONTAL_SCROLL | 
        Manager.USE_ALL_HEIGHT | Manager.USE_ALL_WIDTH ) {

        //Override the paint method to draw the background image.
        public void paint(Graphics graphics) {
            //Draw the background image and then call paint.
            graphics.drawBitmap(0, 0, 240, 240, backgroundBitmap, 0, 0);
            super.paint(graphics);
        }            
    };

    BasicEditField bef = new BasicEditField("To: ","",50,BasicEditField.FILTER_EMAIL);

    //The LabelField will show up through the transparent image.
    LabelField labelField = new LabelField("This is a label");

    HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT);
    //A bitmap field with a transparent image.
    //The background image will show up through the transparent BitMapField image.
    BitmapField bitmapField = new BitmapField(Bitmap.getBitmapResource("pimdemo_jde.png"), Field.FIELD_BOTTOM);
    horizontalFieldManager.add(bitmapField);

    //Add the fields to the manager.
    verticalFieldManager.add(bef);
    verticalFieldManager.add(labelField);
    verticalFieldManager.add(horizontalFieldManager);

    //Add the manager to the screen.
    mainScreen.add(verticalFieldManager);

    //Push the screen.
    pushScreen(mainScreen);
}
0 голосов
/ 24 сентября 2012
hey it's very simple, just use **setStaus** method for displaying images/icons at the bottom of the screen in the blackberry...
for example 

/**
* Initialize Components
*/
ButtonField btn1 = new ButtonField("Button 1");
ButtonField btn2 = new ButtonField("Button 2");
ButtonField btn3 = new ButtonField("Button 3");

HorizontalFieldManager hfm = new HorizontalFieldManager();
hfm.add(btn1);
hfm.add(btn2);
hfm.add(btn3);


/**
*  Add Components to Screen
*/
setStats(hfm);

the setStatus is MainScreen Class method , you can directly use this method in any class that extends MainScreen. & you can find setStatus method in BB 5.0 & above 5.0 OS.
for more info checkout this link :-
http://www.blackberry.com/developers/docs/6.0.0api/index.html 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...