2013-01-16 1 views
15

私はブラックベリーの初心者で、オプション付きのメニューを作成しています。各オプションには、ビットマップイメージとラベルが含まれています。BlackBerryのフォーカスを変更している間に、フィールドマネージャの背景イメージを変更するには

これは、最初のメニュー項目のためのコードです:

hmf1_vfm1 = new VerticalFieldManager(Field.FIELD_HCENTER |   VErrticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.FIELD_HCENTER | VerticalFieldManager.FOCUSABLE | Field.FOCUSABLE) 
{ 
boolean isFocus; 
//Bitmap bmp1 = Bitmap.getBitmapResource("mnu_tile1.png"); 
protected void sublayout(int maxWidth, int maxHeight) 
{ 
super.sublayout(100,125); 
setExtent(100,125); 
} 

protected void paint(Graphics g) { 
try 
{ 
    //g.setBackgroundColor(0x504A4B); 
    //g.drawBitmap(0, 0, bmp1.getWidth(), bmp1.getHeight(), bmp1, 0, 0); 
        g.clear(); 
    Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("mnu_tile1.png")); //mnu_tile1.png 
        this.setBackground(bg); 
        super.paint(g); 
       } 
       catch (IllegalArgumentException e) { 
        //SupportClass.showLog(TAG+" err 2 : "+e); 
       } 
      } 

      protected void onFocus(int direction) { 
       isFocus = true; 
       super.onFocus(direction); 
      } 
      protected void onUnfocus() { 
       isFocus = false; 
       super.onUnfocus(); 
      } 

      protected boolean navigationClick(int status, int time) { 

       //SupportClass.showLog("New Order...navigationClick"); 
       return true; 
      } 
      public boolean isFocusable() { 
       return true; 
      } 
      /*protected boolean touchEvent(net.rim.device.api.ui.TouchEvent message) { 

       //SupportClass.showLog("New Order...touchEvent"); 
       return true; 
      };*/ 
     }; 

ビットマップ&ラベルフィールドは、このVFMに追加されます。

BitmapField bfNO = new BitmapField(bmpNO,Field.FIELD_HCENTER | Field.FOCUSABLE) 
     { 
      protected boolean navigationClick(int status, int time) { 
       SupportClass.showLog("bitmap...navigationClick"); 
       return true; 
      } 
      protected void paint(Graphics graphics) { 
       //this.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.BLACK,0)); 
       super.paint(graphics); 
      } 
     }; 

LabelField txtNO = new LabelField("New Order",LabelField.FIELD_HCENTER | Field.FOCUSABLE) 
     { 
      protected void paint(Graphics g) { 
       g.setColor(Color.WHITE); 
       //g.setBackgroundColor(0x00000000); 
       super.paint(g); 
      } 
      protected boolean navigationClick(int status, int time) { 
       SupportClass.showLog("lable...navigationClick"); 
       return true; 
      } 
     }; 
  • ような方法で、私は背景を見ることができない背景を設定しながら、画像&ラベルを含む垂直フィールドマネージャーを集中したいです。私はいくつかのレイヤーが背景に重なっていると思います。

  • また、フィールドのセレクタの色(青い背景)を透明に変更したいとします。

  • 私が間違いをしていると教えてください。

+0

ここのPictureBackgroundButtonField.javaをチェックしましたか? http://stackoverflow.com/questions/8942225/tab-bar-in-blackberry-without-toolbarmanager/8967671#8967671 – alishaik786

+0

これは1年以上前に尋ねられました。 OPがまだ回答に興味がある場合は、質問を更新してください。私はいくつかの支援を提供します。それ以外の場合は、コードが特定のものであるため、これに答える価値がないように見えます。これに対して可能な一般的な点は、他のより良い質問ですでにカバーされていると思われます。 –

答えて

0

こんにちは、invalidate()メソッドを試してみてください。

関連する問題