0
我正在開發一個應用程序,使用一些圖像。我們需要在圖像上打印一些文字,但這並不是一個固定的意思,當更改變量值時會自動更改文字。簡單地說,我們在圖像上打印一個變量?更新的圖像
我正在開發一個應用程序,使用一些圖像。我們需要在圖像上打印一些文字,但這並不是一個固定的意思,當更改變量值時會自動更改文字。簡單地說,我們在圖像上打印一個變量?更新的圖像
試試這個
public class Test extends UiApplication {
public static void main(String[] arg) {
Test app = new Test();
app.enterEventDispatcher();
}
public Test() {
MyScreen screen = new MyScreen();
pushScreen(screen);
}
}
class MyScreen extends MainScreen {
LabelField label;
public MyScreen() {
label = new LabelField() {
protected void paint(Graphics g) {
Bitmap bitmap = Bitmap.getBitmapResource("bgimage.jpg");
g.drawBitmap(0, 0, getWidth(), getHeight(), bitmap, 0, 0);
super.paint(g);
}
};
ButtonField button = new ButtonField("update") {
protected void fieldChangeNotify(int context) {
update();
super.fieldChangeNotify(context);
}
};
add(label);
add(button);
}
public void setMessage(String message) {
synchronized (UiApplication.getEventLock()) {
label.setText(message);
}
}
private void update() {
LocationHandler handler = new LocationHandler(this);
handler.start();
}
}
class LocationHandler extends Thread {
private MyScreen screen;
public LocationHandler(MyScreen screen) {
this.screen = screen;
}
public void run() {
Criteria criteria = new Criteria();
criteria.setVerticalAccuracy(50);
criteria.setHorizontalAccuracy(50);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);
try {
LocationProvider provider = LocationProvider.getInstance(criteria);
Location location = provider.getLocation(-1);
String speed = location.getSpeed() + "m/s";
screen.setMessage(speed);
} catch (LocationException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
標籤是恆定的,但我們需要一個變量意味着值將是變化的傳球時間。例如加速它的時間變化不是一個常數。並以數字形式顯示。 – 2010-06-21 08:00:26
http://www.techradar.com/news/computing/apple/top-20-best-free-iphone-apps-663484?artc_pg=1 檢查此鏈接並查看卡路里應用程序。在這個應用程序中的GPS和速度顯示在圖像上。 – 2010-06-21 08:03:24
誰說標籤是不變的看到我編輯的帖子。 – Vivart 2010-06-21 08:39:51