我正在尝试在我的黑莓应用程序中添加地图字段,但在导航到该屏幕时出现异常,提示 IllegalArgumentException(位图太大)。任何想法?
代码:
package com.quadrazol.bb.fpg.screens.maps;
import net.rim.device.api.lbs.maps.ui.MapField;
import net.rim.device.api.lbs.maps.model.MapDataModel;
import net.rim.device.api.lbs.maps.model.MapLocation;
import net.rim.device.api.lbs.maps.model.Mappable;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.VerticalFieldManager;
import com.quadrazol.bb.fpg.screens.TabScreen;
import com.quadrazol.bb.fpg.util.DataHelper;
import com.quadrazol.bb.fpg.util.UIHelper;
public class FindAPlannerScreen extends TabScreen {
private MapField basicMapField;
public FindAPlannerScreen() {
super();
VerticalFieldManager mgr = new VerticalFieldManager(
VerticalFieldManager.USE_ALL_HEIGHT
| VerticalFieldManager.USE_ALL_WIDTH
| VerticalFieldManager.NO_VERTICAL_SCROLL) {
public void paint(Graphics graphics) {
graphics.setBackgroundColor(Color.BLACK);
graphics.clear();
super.paint(graphics);
}
};
add(mgr);
mgr.add(UIHelper.generateHeader());
mgr.add(new SeparatorField() {
public void paint(Graphics graphics) {
graphics.setColor(Color.WHITE);
super.paint(graphics);
}
});
VerticalFieldManager mainScrollView = UIHelper.generateMainScrollView();
basicMapField = new MapField(mainScrollView.getWidth()-6,(int) (mainScrollView.getHeight()*.90));
MapDataModel model = basicMapField.getModel();
Mappable[] plannerDetails = DataHelper.fetchPlannerDetails();
if (plannerDetails != null) {
model.addAll(plannerDetails);
}
mainScrollView.add(basicMapField);
mgr.add(mainScrollView);
mgr.add(UIHelper.generateTabBarForScreen(UIHelper.TAB_MAP));
}
}
例外:
[0.0] ViewEngine$RenderingEngine:unknown exception occured, IllegalArgumentException(Bitmap is too large)
[0.0] IllegalArgumentException
[0.0] Bitmap is too large
[0.0] net_rim_cldc-10(4C48DD41)
[0.0] Bitmap
[0.0] <init>
[0.0] 0x8778
[0.0] net_rim_cldc-10(4C48DD41)
[0.0] Bitmap
[0.0] <init>
[0.0] 0x8628
[0.0] net_rim_cldc-10(4C48DD41)
[0.0] Bitmap
[0.0] <init>
[0.0] 0x8609
[0.0] net_rim_cldc-10(4C48DD41)
[0.0] Bitmap
[0.0] <init>
[0.0] 0x85ED
[0.0] net_rim_cldc-10(4C48DD41)
[0.0] Bitmap
[0.0] <init>
[0.0] 0x859E
[0.0] net_rim_bb_maps_api-4(4C48E231)
[0.0] ViewEngine
[0.0] generateContext
[0.0] 0x6457
[0.0] net_rim_bb_maps_api-4(4C48E231)
[0.0] ViewEngine$RenderingEngine
[0.0] <private>
[0.0] 0x65F2
[0.0] net_rim_bb_maps_api-4(4C48E231)
[0.0] ViewEngine$RenderingEngine
[0.0] run
[0.0] 0x6507
PS:我也对net.rim.device.api.lbs.maps.ui.MapField
and的使用感到困惑net.rim.device.api.lbs.MapField
更新:
我按照您的建议进行了尝试,但仍然抛出相同的错误。我注意到一件奇怪的事情。更新后的代码如下:
int displayWidth = Display.getWidth();
int displayHeight = Display.getHeight();
basicMapField = new MapField(displayWidth / 2, displayHeight / 2);
System.out.println("Display Dimen:"+displayHeight+" "+displayWidth);
System.out.println("Map Dimen:"+basicMapField.getHeight()+" "+basicMapField.getWidth());
但在日志中我没有看到参数集。日志显示:
[0.0] Display Dimen:480 360
[0.0] Map Dimen:0 0