私はブラックベリーUIの開発に非常に慣れています。ビットマップにヒントボックスを追加する方法はありますか?ちょうどHTMLの要素内のtitle属性のようブラックベリーUIのヒントボックス
0
A
答えて
2
あなたは、次のTooltipScreenを使用して、次のように画面にフィールドを追加することができます
add(new ButtonField(“myButton”), “My Tooltip text”);
TooltipScreenは
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.container.MainScreen;
public class TooltipScreen extends MainScreen {
TooltipScreen screen = this;
boolean doRedraw = false;//prevent infinte redrawing
Vector tooltips = new Vector();//vector to hold tooltip strings
private Timer tooltipTimer = new Timer();
private TimerTask tooltipTask;
boolean alive = false;//is the tooltip alive? used to pop it after our timeout
int count = 0;//used to calculate time tooltip is displayed
//tooltip popup colours:
int backgroundColour = 0xeeeeee;
int borderColour = 0xaaaaaa;
int fontColour = 0x666666;
//the tooltip:
String tooltip;
int tooltipWidth;
int yCoord;
int xCoord;
//region parameters:
XYRect contentArea;
int contentBottom;
int contentRight;
public TooltipScreen() {
super();
//when timeout reaches 100ms*20 ie. 2seconds set alive to false and redraw screen:
tooltipTask = new TimerTask() {
public void run() {
if (alive) {
count++;
if (count == 20) {
alive = false;
invalidate();
}
}
}
};
tooltipTimer.scheduleAtFixedRate(tooltipTask, 100, 100);
}
//override add method adds an empty string to tooltip vector:
public void add(Field field) {
tooltips.addElement("");
super.add(field);
}
//custom add method for fields with tooltip: add(myField, "myTooltip");
public void add(Field field, String tooltip) {
super.add(field);
tooltips.addElement(tooltip);
}
public void setColours(int backgroundColour, int borderColour, int fontColour) {
this.backgroundColour = backgroundColour;
this.borderColour = borderColour;
this.fontColour = fontColour;
}
//reset everything when user changes focus,
//possibly needs logic to check field has actually changed (for listfields, objectchoicefields etc etc)
protected boolean navigationMovement(int dx, int dy, int status, int time) {
count = 0;
alive = true;
doRedraw = true;
return super.navigationMovement(dx, dy, status, time);
}
protected void paint(Graphics graphics) {
super.paint(graphics);
if (alive) {
Field focusField = getFieldWithFocus();
tooltip = (String) tooltips.elementAt(screen.getFieldWithFocusIndex());
//don't do anything outside the norm unless this field has a tooltip:
if (!tooltip.equals("")) {
//get the field content region, this may fall inside the field actual region/coordinates:
contentArea = focusField.getContentRect();
contentBottom = contentArea.y + contentArea.height;
contentRight = contentArea.x + contentArea.width;
//+4 to accomodate 2 pixel padding on either side:
tooltipWidth = graphics.getFont().getAdvance(tooltip) + 4;
yCoord = contentBottom - focusField.getManager().getVerticalScroll();
//check the tooltip is being drawn fully inside the screen height:
if (yCoord > (getHeight() - 30)) {
yCoord = getHeight() - 30;
}
//check the tooltip doesn't get drawn off the right side of the screen:
if (contentRight + tooltipWidth < getWidth()) {
xCoord = contentRight;
} else {
xCoord = getWidth() - tooltipWidth;
}
//draw the tooltip
graphics.setColor(backgroundColour);
graphics.fillRect(xCoord, yCoord, tooltipWidth, 30);
graphics.setColor(borderColour);
graphics.drawRect(xCoord, yCoord, tooltipWidth, 30);
graphics.setColor(fontColour);
graphics.drawText(tooltip, xCoord + 2, yCoord);
}
}
//doRedraw logic prevents infinite loop
if (doRedraw) {
//System.out.println("redrawing screen: " + System.currentTimeMillis());
screen.invalidate();
doRedraw = false;
}
}
}
+0
thnx rfsk2010この種の私の問題を解決する –
+0
あなたはそれが働いてうれしい – rfsk2010
関連する問題
- 1. ブラックベリーUIのツールバーをiPhoneのように作るためのガイドライン
- 2. ブラックベリーのバックグラウンドスレッドからUIに画像を表示する
- 3. ブラックベリーのサービススレッドは、実行時にUIをハングします
- 4. ブラックベリーで2つのUIスレッドLWUITを実装するには?
- 5. はブラックベリー:PhoneLogs.deleteCall()ブラックベリー6.0で
- 6. ブラックベリー:
- 7. ブラックベリー
- 8. ブラックベリーでタブバーアプリケーションUIを作成する方法...?
- 9. ブラックベリーのOCRライブラリ
- 10. ブラックベリーの画面
- 11. ブラックベリーの低レベルグラフィックス
- 12. ブラックベリーのキュースレッド
- 13. ブラックベリーのMDS-CS
- 14. ブラックベリーのボタン
- 15. ブラックベリーのカスタムマルチラインテキストボックス
- 16. ブラックベリーのデバッグコード
- 17. リストフィールドのブラックベリー
- 18. ブラックベリーのチャットアプリ
- 19. ブラックベリーのスタンドアロンメールAPI
- 20. ブラックベリー:BitmapField
- 21. ブラックベリーwebservice
- 22. ブラックベリーのJava Webサービスエラー
- 23. ブラックベリーのプッシュ通知
- 24. ブラックベリーの野外アニメーション
- 25. ブラックベリーAPNの設定
- 26. ブラックベリーの永続ストレージ
- 27. ブラックベリーの永続ストア
- 28. ブラックベリーのデータベース問題
- 29. ブラックベリーの表はIllegalStateException
- 30. ブラックベリーのマネージャーでSetMargin
あなたが使用してそれを行うことができます'BitmapField'と' LabelField'を作成し、 'VerticalFieldManger'または' HorizontalFieldManager'に追加します。また、カスタムの 'Field'を書くこともできます。 – Rupak
あなたのコメントをお寄せいただきありがとうございます。実際に私の画面上にBitMapFieldがあります。このBitmapFieldがフォーカスされている、または抱かれていたときにタイトルを表示するだけで、このページのTwitter、Facebook、Google +使用していますJDE6 –