点击确认后,Choreographer就开始疯狂的刷屏,找不到原因.... /** * 自定义一个alertDialog,设置防盗密码 */ public void showDialog() { AlertDialog.Builder builder = new Builder(this); // 填充dialog的UI界面 View dialogView = View.inflate(this, R.layout.dialog_ui, null); builder.setView(dialogView); //为了取消dialog,需要将builder转成dialog final AlertDialog dialog = builder.create(); //拿到控件 mEdt_pwd = (EditText) dialogView.findViewById(R.id.edt_pwd); mComfilm_pwd = (EditText) dialogView.findViewById(R.id.edt_comfilm_pwd); //设置确定和取消的点击事件 dialogView.findViewById(R.id.but_comfilm).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //拿到密码 mPwd = mEdt_pwd.getText().toString(); mCom_pwd = mComfilm_pwd.getText().toString(); if (TextUtils.isEmpty(mPwd) || TextUtils.isEmpty(mCom_pwd)) { MyToast.showShort(MainActivity.this, "密码不能为空"); return; } else if (!mPwd.equals(mCom_pwd)) { MyToast.showShort(MainActivity.this, "密码输入不一致"); return; } //将密码保存到配置文件中 PerferenseUtil.putString(MainActivity.this, Constant.REGISTER_KEY, mPwd); MyToast.showShort(MainActivity.this, "进入防盗的设置第一页"); // 4. 取消对话框 dialog.dismiss(); } }); dialogView.findViewById(R.id.but_cancel).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
这个是我的Dialog_ui <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="45dp" android:background="#ECECEE" android:drawableLeft="@drawable/dialog_title_default_icon" android:gravity="center_vertical" android:text="初始化密码设置" android:textSize="18sp" /> <EditText android:id="@+id/edt_pwd" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" android:hint="请输入密码" android:password="true" /> <EditText android:id="@+id/edt_comfilm_pwd" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" android:hint="请确认密码" android:password="true" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/but_comfilm" android:background="@drawable/selector_dialog_button" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="确定" /> <Button android:id="@+id/but_cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="取消" /> </LinearLayout> </LinearLayout>
小寳_昭乂阳
相关分类