【问题标题】:How to show images in the place of label in black berry screen using eclips plugin如何使用eclipse插件在黑莓屏幕的标签位置显示图像
【发布时间】:2010-06-17 20:14:07
【问题描述】:

我正在使用 Eclipse 开发一个黑莓应用程序,我需要在标签的位置显示图像,例如新按钮在我需要显示一些图像的新按钮的位置。我如何显示图像,你可以举一个例子。

谢谢你

【问题讨论】:

    标签: eclipse blackberry


    【解决方案1】:

    试试这个

        import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Graphics;
    
    public class CustomButton extends Field {
    
        final Bitmap bitmap1;
        final Bitmap bitmap2;
        Bitmap bitmap;
    
        CustomButton() {
            bitmap1 = Bitmap.getBitmapResource("button_01.jpg");
            bitmap2 = Bitmap.getBitmapResource("button_02.jpg");
            bitmap = bitmap1;
        }
    
        public int getPreferredHeight() {
            return bitmap1.getHeight();
        }
    
        public int getPreferredWidth() {
            return bitmap1.getWidth();
        }
    
        protected void paint(Graphics g) {
            g.drawBitmap(0, 0, getWidth(), getHeight(), bitmap, 0, 0);
        }
    
        protected void fieldChangeNotify(int context) {
            try {
                getChangeListener().fieldChanged(this, context);
            } catch (Exception exception) {
            }
        }
    
        public boolean isFocusable() {
            return true;
        }
    
        protected void layout(int width, int height) {
    
            setExtent(Math.min(width, getPreferredWidth()), Math.min(height,
                    getPreferredHeight()));
        }
    
        protected void onFocus(int direction) {
            bitmap = bitmap2;
            invalidate();
        }
    
        protected boolean navigationClick(int status, int time) {
            fieldChangeNotify(1);
            return true;
        }
    
        protected void onUnfocus() {
            bitmap = bitmap1;
            invalidate();
        }
    
    }
    

    然后这样调用

    CustomButton button = new CustomButton(){
                protected void fieldChangeNotify(int context) {
                    //button click
                    super.fieldChangeNotify(context);
                }
            };
    

    【讨论】:

    • 我需要图像代替按钮,当我们点击图像时,它将充当按钮,我们该怎么做..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 2010-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多