android上的全屏自定义对话框

时间:2016-03-07 02:33:10

标签: android

最近,我有自定义对话框代码。

我想要全屏自定义对话框。

如何在android

上全屏自定义对话框
public class MainActivity extends AppCompatActivity {
static Process rebootProcess;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(false);
    builder.setTitle("Warning~~");
    builder.setMessage("reboot")
            .setPositiveButton("ok",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    try {
                        rebootProcess = Runtime.getRuntime().exec(new String[]{"su", "-c", "poweroff"});
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    dialog.dismiss();
                }
            });
    builder.create().show();
}

1 个答案:

答案 0 :(得分:0)

在onCreate中,创建一个对话框

//将布局文件设计为全屏

Dialog mDialog = new Dialog(this);
// set other paramters for dialog
mDialog.setContentView(R.layout.your_layout_file);