[java] <span style="white-space:pre"> </span>View view = View.inflate(StatusBarService.this, R.layout.power_off_dialog, null); AlertDialog.Builder b = new AlertDialog.Builder(StatusBarService.this); b.setView(view); final AlertDialog d = b.create(); d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); //系統(tǒng)中關(guān)機(jī)對(duì)話框就是這個(gè)屬性 //d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //窗口可以獲得焦點(diǎn),響應(yīng)操作 //d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); //窗口不可以獲得焦點(diǎn),點(diǎn)擊時(shí)響應(yīng)窗口后面的界面點(diǎn)擊事件 d.show(); Button yesButton = (Button) view.findViewById(R.id.yes_button); Button canclButton = (Button) view.findViewById(R.id.cancl_button); yesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN); intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); canclButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { d.dismiss(); } }); |
|