public class MainActivity extends Activity {
EditText editText1, editText2, editText3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
//自定义View对话框
public void customView(View source)
{
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
.setIcon(R.mipmap.ic_launcher)
.setTitle("自定义View对话框")
.setView(R.layout.login)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (TextUtils.isEmpty(editText1.getText().toString()) ||
TextUtils.isEmpty(editText2.getText().toString()) ||
TextUtils.isEmpty(editText3.getText().toString())) {
Toast.makeText(MainActivity.this, "请填写完整", Toast.LENGTH_SHORT).show();
//不满足条件,“确定”按钮无效
try {
Field field = dialog.getClass().getSuperclass()
ALertDialog自定义View对话框 获得View上的输入信息 + 点击按钮满足条件后消失
最新推荐文章于 2024-05-27 15:37:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)