i am developing an application that use some images. We require some text print on image but that is not a fixed mean when change the variable value automatically change the text. Simply we say that we print a variable on image?
A:
try this
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();
}
}
}
Vivart
2010-06-21 07:46:39
label is a constant but we require a variable means that's value will be change passing of time. for example speed its not a constant its change time to time. and i show in numeric form.
jutt.chattha
2010-06-21 08:00:26
http://www.techradar.com/news/computing/apple/top-20-best-free-iphone-apps-663484?artc_pg=1check this link and see the calories application. in this application GPS and Speed show on a image.
jutt.chattha
2010-06-21 08:03:24
who said that label is constant see my edited post.
Vivart
2010-06-21 08:39:51
still same problem. update is fixed but we not require fix
jutt.chattha
2010-06-21 11:39:16
not constant label require require variable label that change time to time. and thanks for help
jutt.chattha
2010-06-21 13:19:21
you can use label.setText() to change the displayed text...
ADB
2010-06-22 18:51:43