2012-03-12 10 views
0

現在、私のアプリケーションには4つのビットマップボタンがあります。私は誰かが特定のボタンに集中するたびに、その名前が画面のどこかに現れるように、各ボタンのLabel/Nameのようなものを持っています。一番上にあっても、ボタンの下にあっても、どこでもかまいません。ビットマップボタンフィールドのラベル/名前

どうすればいいですか?私はビットマップボタンフィールドのラベルを検索しようとしましたが、本当に有用なものは何も見つかりませんでした。

答えて

3

ボタンフィールドの下にCustomLabelFieldを配置することができます。 ButtonFields onFocus(int direction)およびonUnfocus()メソッドをオーバーライドします。それらの中にあなたがこのカスタムボタンを使用して、それにあなたの追加機能を追加することができます(コメントの後に)あなたのCustomLabelField

class CustomLabelField extends Field { 
    String label; 
    public void setLabel(String label){ 
     this.label = label; 
     invalidate(); 
    } 
    protected void layout(int arg0, int arg1) { 
     setExtent(Display.getWidth, getFont().getHeight()); 
    } 

    protected void paint(Graphics graphics) { 
     graphics.setColor(Color.Black); 
     graphics.drawText(label, 0, 0); 
    } 
} 

EDIT

setLabel(String label)メソッドを呼び出します。これがうまくいけば試してみませんでしたが、うまくいくはずです。

import net.rim.device.api.ui.component.BitmapField; 
import net.rim.device.api.ui.container.MainScreen; 

public class CustomButtonField extends BitmapField{ 
    private String label = ""; 
    private MainScreen yourScreen; 

    public CustomButtonField(String label, MainScreen yourScreen) { 
     super(); 
     this.label = label; 
     this.yourScreen = yourScreen; 
    } 

    protected void onFocus(int direction) { 
     yourScreen.setTitle(label); 
     super.onFocus(direction); 
    } 

    protected void onUnfocus() { 
     yourScreen.setTitle(""); 
     super.onUnfocus(); 
    } 
} 
+0

私は過書き込みアプリケーションのタイトルバーをにラベルをご希望の場合、それは可能ですか?しかし、それは良い助けです、ありがとうございます〜 – ocinisme

+0

はい、可能です。 –

+0

どうやって説明すればいいですか? – ocinisme

関連する問題