我想在黑莓屏幕底部显示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);
}
}
答案 0 :(得分:1)
我稍微修改了你的代码。
首先,添加占据所有显示高度的VerticalFieldManager
并垂直对齐字段。 VFM保存除BitmapField之外的所有字段。然后添加了HorizontalFieldManager
,占据了可用显示高度的其余部分。最后,BitmapField被添加到HFM,样式为 FIELD_BOTTOM ,告诉HFM将字段与经理的底部对齐。
如果您想在屏幕底部添加更多图像,只需使用FIELD_BOTTOM样式对其进行实例化,然后将它们添加到HFM。
检查此answer以获取有关字段对齐的更多信息。
以下是具有上述修改的代码
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);
}
答案 1 :(得分:0)
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