欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

dialo

程序员文章站 2022-07-01 20:29:33
...

private void showDialogs() {
View view = LayoutInflater.from(getContext()).inflate(R.layout.high_dialog_layout, null, false);
final AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view).create();

    TextView login_text = view.findViewById(R.id.login_text);
    TextView btn_cancel_high_opion = view.findViewById(R.id.cancel_button);
    TextView btn_agree_high_opion = view.findViewById(R.id.ok_button);

    login_text.setText("您确定要登录吗?");
    btn_cancel_high_opion.setOnClickListener(new View.OnClickListener() {//同意
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    btn_agree_high_opion.setOnClickListener(new View.OnClickListener() {//取消
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), LoginActivity.class));
            dialog.dismiss();
        }
    });

    dialog.show();
    //此处设置位置窗体大小,我这里设置为了手机屏幕宽度的3/4  注意一定要在show方法调用后再写设置窗口大小的代码,否则不起效果会
    dialog.getWindow().setLayout((ScreenUtils.getScreenWidth() / 4 * 3), LinearLayout.LayoutParams.WRAP_CONTENT);
}
相关标签: 哈哈

推荐阅读