0

在下面的代码中,我只是试图从 EditText 中获取片段中的登录名和密码的值。它们都没有返回任何值,因为它们都在加载 App 时检索了值。我注意到 onCreateView 仅在加载应用程序时调用一次,并且在加载后输入它们时永远不会返回 Edittext 值

公共类片段登录扩展片段{

        EditText login;
        EditText password;
        Button send;
        String USERNAME ;  // your account's username
        String PASSWORD ;   // your account's password
       
        private static final String ARG_PARAM1 = "param1";
        private static final String ARG_PARAM2 = "param2";
        private String mParam1;
        private String mParam2;
    
    
        public fragment_login() {
            // Required empty public constructor
        }
    

        public static fragment_login newInstance(String param1, String param2) {
            fragment_login fragment = new fragment_login();
            Bundle args = new Bundle();
            args.putString(ARG_PARAM1, param1);
            args.putString(ARG_PARAM2, param2);
    
    
            fragment.setArguments(args);
            return fragment;
        }
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            View v = inflater.inflate(R.layout.fragment_login, container, false);
            login = v.findViewById(R.id.et_email);
            String bing=login.getText().toString();
            password = v.findViewById(R.id.et_password);
            String bong=password.getText().toString();
    
            send = v.findViewById(R.id.btn_login);
             return v;
    
        }

        @Override
        public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    
          
            send.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
    
                    callFunction();
    
                }
            });
        }
4

0 回答 0