【问题标题】:How to make bitmapfield focusable and clickable如何使位图字段可聚焦和可点击
【发布时间】:2012-12-28 19:14:04
【问题描述】:

我正在做一个黑莓,在我的应用程序中,我必须使位图字段可点击和聚焦。这是我的示例代码。

 bf=new BitmapField(logo,BitmapField.FOCUSABLE){
 protected boolean navigationClick(int status, int time) {
 Dialog.inform("haaaaaaaaaaaai");
 return true;
  };
 protected void layout(int width, int height) {
            // TODO Auto-generated method stub
            super.layout(width, height);
            setExtent(120, 110);
        }
};

我将此字段添加到垂直字段管理器。现在的问题是,如果我单击屏幕上的任何位置,动作正在发生并且它没有显示任何焦点的迹象。请帮助我的朋友。

【问题讨论】:

标签: blackberry


【解决方案1】:

BitmapField 包含 Bitmap,所以蓝色的可聚焦矩形被位图覆盖。如果要显示可聚焦的 BitmapField,则需要:

  1. 使用低不透明度图像。 或
  2. 使用图像周围有 2 像素或更多像素的透明填充。

对于第二个问题,可以在 BitmapField 之前添加 NullField,因为默认情况下第一个字段在屏幕上具有焦点。在您的情况下,屏幕上只有一个字段可用。

【讨论】:

    【解决方案2】:

    查看Advanced UI。并寻找位图按钮。 :)

    【讨论】:

      【解决方案3】:

      要使位图字段可聚焦和可点击,只需使用以下代码:-

      Bitmap myBitmap = Bitmap.getBitmapResource("image.png");
      
          BitmapField icImg = new BitmapField(myBitmap, BitmapField.FOCUSABLE)
          {
            protected boolean navigationClick(int status, int time) 
              {
      
                UiApplication.getUiApplication().pushScreen( new SCREENCLASS());
                     return true;
               }
          };
      add(icImg)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-15
        • 1970-01-01
        • 1970-01-01
        • 2011-06-27
        • 1970-01-01
        • 2014-08-01
        相关资源
        最近更新 更多