Android Case one Phone Dialer

Source: Internet
Author: User

: The core principle of telephone dialer:   Intent mainactivity Code:    Private Edittest et_number;//loading a layout setcontentview (R.layout.main);  //gets the desired control editTest1 Button1 et_number = (edittest) Findviewbyid (r.id.edittest1);  button Btn_call = ( button) Findviewbyid (r.id.button1)  //for button Btn_call set Click events   Implement an inner class Btn_call.setonclicklistener (new Myclicklistener ());  //Inner class implement Click event Private class Myclicklistener (View v) {        String number = et _number.gettext (). toString (). Trim ();        if ("". Equals (number)) {            Toast.maketest (Mainactivity.this, "mobile phone number cannot be empty! ", Length_long);}        //Create an intent         Intent Intent = new Intent ();       / /Set Intent action         intent.setaction (intent.action_call);         //Set Intent data         Intent.setdata (Uri.parse ("Tel:" +number);         //Open Intent         startactivity (intent);} Summary: 1. Intent: First step: Create intent intent Intent = new Intent ();  second step: Set action Intent.setaction (string);  step three: Set Object Intent.setdata ( Path);  Fourth step: Open Intent startactivity (intent);  2. Four ways to implement the Click event: 
    1. Inner class
      Btn_call.setonclicklistener (interface type new Myclicklistener ());
      Private Class Myclicklistener (View v) {
      Callphone ();
      }

    2. Anonymous inner class
      Btn_call.setonclicklistener (New Onclicklistener (View v) {
      Implement the OnClick () method that is not implemented in the Onclicklistener class

    3. Mainactivity implementation of Onclicklistener-------------for multiple buttons
      Btn_call1.setonclicklistener (this);
      Btn_call2.setonclicklistener (this);
      Btn_call3.setonclicklistener (this);
      Switch (V.getid ()) ....
    4. Write a class with the same name as the Click Property. Implement click events in this class






Android Case one Phone Dialer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.