【发布时间】:2012-02-09 18:30:15
【问题描述】:
我是 Android 新手。我想在手机中制作一个电池充电动画,例如,在屏幕右上角,充电时上下颠倒的小图标,在当前电池百分比时停止.
到目前为止,在我的代码中,我已经能够让它移动,但它永远不会停止。
我想要的是动画在不充电时停止或在当前电池百分比时停止。
这是我在动画中的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.batteryinfo);
ImageView batteryImage = (ImageView) findViewById(R.id.BatteryImage);
batteryImage.setBackgroundResource(R.drawable.ic_battery_animation);
BatteryAnimation = (AnimationDrawable) batteryImage.getBackground();
batteryImage.post(new Starter());
textBatteryLevel = (TextView) findViewById(R.id.batterylevel_text);
registerBatteryLevelReceiver();
}
class Starter implements Runnable {
public void run() {
BatteryAnimation.start();
}
}
到目前为止,我可以获得电池状态、插头类型和电池的健康状况。
【问题讨论】:
标签: java android android-animation power-management