0
私は1つのレイアウトを持ち、2つの異なるインスタンスを表示するために使用します。以下のコードを見てください。私はこのロジックがうまくいくはずですが、動作していないと思います。いつかレイアウトを拡張する方法は?
setContentView(R.layout.notification);
//Notify user if Battery level is low
if (iBatlevel <= 50)
{
ImageButton CamButton = (ImageButton) findViewById(R.id.imageButton2);
CamButton.setVisibility(View.GONE);
ImageButton PButton = (ImageButton) findViewById(R.id.imageButton1);
PButton.setVisibility(View.GONE);
ProgressBar _batPB = (ProgressBar) findViewById(R.id.progressBar);
_batPB.setProgress(iBatlevel);
_batPB.setVisibility(View.VISIBLE);
TextView _batText = (TextView) findViewById(R.id.notifymsg);
_batText.setText("!!! Low Battery !!!\n"+Integer.toString(iBatlevel)+"%"+" remaining");
//Wait for 4 seconds
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
}
}, 400000);
}
/*****************************************************************************************/
//To check whether SDcard is present are not
boolean isSDCardPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
// Intent intent = null;
if(isSDCardPresent)
{
// setContentView(R.layout.sdcard);
ImageButton CamButton = (ImageButton) findViewById(R.id.imageButton2);
CamButton.setVisibility(View.VISIBLE);
ImageButton PButton = (ImageButton) findViewById(R.id.imageButton1);
PButton.setVisibility(View.VISIBLE);
ProgressBar _batPB = (ProgressBar) findViewById(R.id.progressBar);
_batPB.setVisibility(View.GONE);
Drawable warning_img = getApplicationContext().getResources().getDrawable(R.drawable.warning);
TextView warning = (TextView) findViewById(R.id.notifymsg);
warning.setText("SDcard not found !!!");
warning_img.setBounds(0, 0, 30, 30);
warning.setCompoundDrawables(warning_img, null, null, null);
// intent = new Intent(this,SDcard.class);
// startActivity(intent);
// finish();
}
バッテリーが低い場合は、対応するレイアウトは、いくつかの時間を表示し、他のが、バッテリのループが真のですが、私は唯一のSDカードビューを取得する必要があります。どのように周りを移動する任意のアイデアですか?