/*** * 自定义弹出框 */ AlertDialog.Builder builder = new AlertDialog.Builder(LiveStartdirectLiveActivity.this); LayoutInflater inflater = LayoutInflater.from(this); View view = inflater.inflate(R.layout.live_direct_live_cancel_or_ok_dialog, null); builder.setView(view); builder.setCancelable(false); dialog = builder.create(); dialog.show(); TextView tv_ok = (TextView) view.findViewById(R.id.ok_tv); TextView tv_cancel = (TextView) view.findViewById(R.id.cancel_tv); TextView tv1 = (TextView) view.findViewById(R.id.tv1); TextView tv2 = (TextView) view.findViewById(R.id.tv2); TextView tv3 = (TextView) view.findViewById(R.id.tv3); /** * 注意,在XML写的内容在dialog中不会显示出来,需要在java代码中写Text才可 */ tv1.setText("根据国家的相关法律法规"); tv2.setText("开启直播必须要进行实名认证"); tv3.setText("是否去实名认证?"); tv_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(); intent.setClass(getApplicationContext(), LiveRealNameActivity.class); startActivity(intent); finish(); } }); tv_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel();//取消弹出框 finish(); } });
android自定义弹出
最新推荐文章于 2019-08-29 16:50:19 发布