How to handle button clicks using the XML onClick within Fragments

前端 未结 18 1747
旧时难觅i
旧时难觅i 2020-11-22 01:41

Pre-Honeycomb (Android 3), each Activity was registered to handle button clicks via the onClick tag in a Layout\'s XML:

android:onClick=\"m         


        
18条回答
  •  野的像风
    2020-11-22 02:13

    This has been working for me:(Android studio)

     @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    
            View rootView = inflater.inflate(R.layout.update_credential, container, false);
            Button bt_login = (Button) rootView.findViewById(R.id.btnSend);
    
            bt_login.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
    
                    System.out.println("Hi its me");
    
    
                }// end onClick
            });
    
            return rootView;
    
        }// end onCreateView
    

提交回复
热议问题