在 BB 设备中显示图像
我使用 BB API 编写了以下代码来显示图像,但它没有在屏幕上显示图像。我尝试显示的图像位于我的 Java 程序所在的文件夹中:
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.MainScreen;
public class BitMapFieldDemo extends UiApplication
{
public static void main(String[] args)
{
BitMapFieldDemo theApp = new BitMapFieldDemo();
theApp.enterEventDispatcher();
}
public BitMapFieldDemo()
{
pushScreen(new BitmapFieldDemoScreen());
}
}
class BitmapFieldDemoScreen extends MainScreen
{
public BitmapFieldDemoScreen ()
{
setTitle("Bitmap Field Demo");
Bitmap bitmapImage = Bitmap.getBitmapResource("D:\\JDE 5.0_WORKSPACE\\CrossPlatformMsngr\\src1.png");
BitmapField fieldDemo = new BitmapField(bitmapImage);
add(fieldDemo);
}
}
Why is my image not getting displayed on screen(为什么我的图像没有显示在屏幕上)。我在代码中遗漏了什么吗?
I have written a following code using BB API to display image but its not showing the image on the screen. The image which I am trying to display is in the folder in which my Java program is present:
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.MainScreen;
public class BitMapFieldDemo extends UiApplication
{
public static void main(String[] args)
{
BitMapFieldDemo theApp = new BitMapFieldDemo();
theApp.enterEventDispatcher();
}
public BitMapFieldDemo()
{
pushScreen(new BitmapFieldDemoScreen());
}
}
class BitmapFieldDemoScreen extends MainScreen
{
public BitmapFieldDemoScreen ()
{
setTitle("Bitmap Field Demo");
Bitmap bitmapImage = Bitmap.getBitmapResource("D:\\JDE 5.0_WORKSPACE\\CrossPlatformMsngr\\src1.png");
BitmapField fieldDemo = new BitmapField(bitmapImage);
add(fieldDemo);
}
}
Why is my image is not getting displayed on screen. Am I missing something in the code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将图像保存在应用程序的资源文件夹(res)中,然后尝试
Bitmap.getBitmapResource("src1.png");
You can save the image in the Resource folder of your application(res),and then try
Bitmap.getBitmapResource("src1.png");