0
我有一個佈局,我用它來顯示兩個不同的實例。請參閱下面的代碼,我想這個邏輯應該可以工作,但它不工作。如何膨脹一個佈局一段時間,然後另一個?
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卡視圖。任何想法如何去?