Android instance-Mobile security Defender (32)-Advanced tools, Number attribution query page

Source: Internet
Author: User
Tags gettext

First, the goal

1, complete the "Advanced Tools" page layout, components, click events and other processing

2. Complete the "Number Attribution query" page layout, components, click events and other processing

Second, the Code implementation

1. Create a new class (named Atoolsactivity) under the project package (Com.example.mobilesafe) to inherit activity as the main page of the Advanced Tools option and register it in the manifest file. At the same time, the new XML file (named Activity_atools) is created as the layout file of the new Class (atoolsactivity) under the Layouts folder under the Res folder.

2, in the Program Main page (homeactivity) ... Case 7 is added to the statement, and the new class is started in 1 through the intent object;

The startup code is as follows:

1  Case 7:// Enter "Advanced Tools"2                     new Intent (homeactivity.  this,3                             atoolsactivity.  Class); 4                     startactivity (intent7); 5                     break;
View Code

3, in the Atoolsactivity class layout file (Activity_atools) as needed to complete the layout of the relevant components, When setting the Click event (OnClick) for the TextView component, it is necessary to set its clickable (clickable) property value to True, in this case the Click event name is "Enternumberaddqueryactivity " and the processing of this click event in the Atoolsactivity class is used to enter the "Number Attribution Query" page from the "Advanced Tools" page;

  4. Because of the Click event ( enternumberaddqueryactivity , enter the number Attribution query page) need to restart an activity, so you need to the Project package (Com.example.mobilesafe) creates a new class (named numberaddqueryactivity ) inherits the activity, implements the number attribution query, then completes the registration in the manifest file, establishes the layout file for it, and completes the related component's layout, the ID, the click event according to the request ( Numberaddquery, check the number of the place of attribution) ;

5, in the Click event (enternumberaddqueryactivity) processing method, through the intent object launches the "Number Attribution to Query" Class (numberaddqueryactivity);

Enternumberaddqueryactivity Click event Handling code:

1  Public void enternumberaddqueryactivity (view view) {2         New Intent (This, numberaddqueryactivity.  Class); 3         startactivity (intent); 4     }
View Code

6, in The "Number Attribution Query" Class (Numberaddqueryactivity) instantiates the related component in the layout file and finds it through the Findviewbyid () method, creating a new click event ( numberaddquery, query number attribution place) processing method;

7, in the Click event (numberaddquery, query number Attribution) processing method, through the EditText object (number_query_phone) of the GetText () method to obtain the text, and then through the ToString () and trim () Method gets the string type of telephone number, determines whether the phone number is empty, if empty, and if not empty, queries the number attribution from the database.

Numberaddquery Click event handling code;

1  Public voidnumberaddquery (view view) {2String Phone_number =Number_query_phone.gettext (). toString (). Trim ();3         if(Textutils.isempty (Phone_number)) {4Toast.maketext ( This, "Query number is empty", Toast.length_short). Show ();5             return;6}Else{7             //go to the database and query the number attribution.8SYSTEM.OUT.PRINTLN ("Query number is:" +phone_number);9         }Ten}
View Code

Android instance-Mobile security Defender (32)-Advanced tools, Number attribution query page

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: 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.