zoukankan      html  css  js  c++  java
  • 【XFeng安卓开发笔记】android 如何在对话框中获取edittext中的数据

    最近做的一个登录对话框,在获取数据的时候出现错误,运行的时候自动死机。

    出错语句:

    EditText PasswordEidtText = (EditText)findViewById(R.id.UserPasswordEidtText); // 发送文本
    String message =PasswordEidtText.getText().toString();

    应该修改为:

    EditText PasswordEidtText = (EditText) DialogView.findViewById(R.id.UserPasswordEidtText); // 发送文本
    String message =PasswordEidtText.getText().toString();

      

    网上搜索的资源:

    //得到自定义对话框
          final View DialogView = a .inflate ( R.layout.loand, null);       

     //创建对话框
            

            AlertDialog dlg = new AlertDialog.Builder(loand.this)
            .setTitle("登录框")
            .setView(DialogView)//设置自定义对话框的样式
          
            .setPositiveButton("登陆", //设置"确定"按钮
          new DialogInterface.OnClickListener() //设置事件监听
            {
             
             
                public void onClick(DialogInterface dialog, int whichButton)
                {
                 editText1 =(EditText) DialogView.findViewById(R.id.editText1);
                 editText2 =(EditText) DialogView.findViewById(R.id.editText2);
                 String id = editText1.getText().toString();
                 String password = editText2.getText().toString();
                     
                 //输入完成后,点击“确定”开始登陆
                 
                 c_log judge = new c_log();
                 boolean b_judge = judge.aa(id,password);
                 if(b_judge){
                  bar();
                 }else{
    //加东西              
                  DisplayToast("NO");
                  
                 }     
                 
                 
                }
            })

  • 相关阅读:
    yolo_to_onnx ValueError: need more tan 1 value to unpack
    yolo_to_onnx killed
    C++ 实现二维矩阵的加减乘等运算
    Leetcode 1013. Partition Array Into Three Parts With Equal Sum
    Leetcode 1014. Best Sightseeing Pair
    Leetcode 121. Best Time to Buy and Sell Stock
    Leetcode 219. Contains Duplicate II
    Leetcode 890. Find and Replace Pattern
    Leetcode 965. Univalued Binary Tree
    Leetcode 700. Search in a Binary Search Tree
  • 原文地址:https://www.cnblogs.com/xiaofeng6636/p/4187660.html
Copyright © 2011-2022 走看看