-1
アンドロイドでバッテリー残量インジケーターを作成する方法は?
バッテリレベルのインジケータを画像(丸で囲んだもの)のように作成したいと思います。緑色の部分は、デバイス内の使用可能なバッテリに基づいて塗りつぶされます。
この
registerReceiver(mBatInfoReceiver, new IntentFilter(
Intent.ACTION_BATTERY_CHANGED));
のようなデバイスからのバッテリーのパーセンテージを取得するので、レイアウトに私は、バッテリーのパーセンテージを表示することができています。
public class BatteryIndicatorActivity extends Activity {
//Create Broadcast Receiver Object along with class definition
private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver() {
@Override
//When Event is published, onReceive method is called
public void onReceive(Context c, Intent i) {
//Get Battery %
int level = i.getIntExtra("level", 0);
TextView tv = (TextView) findViewById(R.id.textfield);
//Set TextView with text
tv.setText("Battery Level: " + Integer.toString(level) + "%");
}
};
しかし、このタイプのバッテリインジケータのUIを作成する方法。このようなタイプのUIを作成する方法ではない場合、これらのAPIはこれを達成するために必要ですか?
あなたのご協力をお待ちしております。
ありがとうございましたVlad ..バッテリーインジケーターを作るサンプルプロジェクトをご利用いただきありがとうございます。 –
@AnurajR、私は誰かがバッテリーインジケータ専用のサンプルを作成したとは思わない –