android-1-Telephone Dialer

Source: Internet
Author: User


Project Package      src--java source code      Gen folder  --resource file, modified automatically generated                    ---R.java in the drawable class corresponding directory drawable directory, layout corresponding                            The layout directory in the directory, string corresponding to       the string directory Assets folder to hold large files: such as video, audio, fonts, etc. (1G will not be compiled)        res folder                    ---drawable picture res storage resource File                     ---layout main. The layout of the Xm interface TextView display content cannot be modified                    ---values  string.xml  storing strings for internationalization        


2. Engineering structure Src:java source code directory (only one package is allowed) androidmainfest.xml (manifest file, description of the application's composition, components, permissions, etc.) Gen/r.java resource files, modified automatically generated Android : Library Assets: Static resource file drawable program icon Layout folder values: Application String color (string.xml) Classes.dex compiled Java binary code Android Executable file 2 on the platform. Android's packaging features Android. App provides a high-level program model that provides basic run-of-the-loop Android. Content access to data on the device and publish the class Android. Database provides browsing and publishing of Android. Graphics bottom of the graphic library Android. Location Locator and related services Android. Media Management Multi-oh audio, video and interface Android. NET provides help for network access to the class Android. OS provides system services, message transmission Output, IPC mechanism Android. OpenGL provides OpenGL tools for Android. Provider: Provides access to Android content Android. Telephony provides the APL interactive Android that is related to making calls. View Provides a basic user interface framework for Android. Util involves a tool-based approach to Android. WebKit Default Browser interface Android. Widgets contain various UI elements that are used in the application's frequency screen 3. The core components of the Android Program view interface views, component UI Control Intent Intent, support communication between components activity: Processing interface Intentreceiver receive information and event Processing service background service Notification: Declaration period for message and notification 4.Activity void OnCreate (Bundle saveinstancestate) void OnStart () void Onrestart () void on Resume () void OnPause () void OnStop () vOID OnDestroy () myandroid1/res/layout/activity_main.xml <textview android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "@string/hello_world"/>/myandroid1/res/values/strings.xml & Lt;string name= "App_name" >Myandroid1</string> <string name= "Action_settings" >settings</string > <string name= "Hello_world" >jia you wangqi!</string> "activity" an activity is an application component that provides a screen, Users can interact in order to complete a task, such as dialing, taking pictures, sending email, and looking at a map. Each activity is given a window on which the user interface can be drawn.  Windows are usually filled with screens, but can also be smaller than the screen and float on top of other windows. An application is usually composed of multiple activities, and they are usually loosely coupled. Typically, activity in an application is designated as "main" activity, which is presented to the user when the application is first launched. Each activity can then start another activity in order to complete a different action. Each time an activity starts, the previous activity stops, but the system retains activity on a stack ("Back stack"). When a new activity is started, it is pushed to the top of the stack to get the user focus.  The back stack conforms to the simple "last in, first out" principle, so when the user finishes the current activity and then clicks the Go button, it is popped up (and destroyed) before the activity resumes. When an activity is stopped due to a new activity initiation, it is notified that this state transitions through the activity's lifecycle callback function. There are many callback functions that an activity may receive, originating from its own state change-whether the system creates it, stops it, restores it, destroys it-and each backProvides you with the opportunity to complete a specific job that fits this state. For example, when you stop, your activity should release any large object, such as a network database connection. When activity resumes, you can regain the necessary resources and restore the interrupted action. These state transitions are part of the activity's life cycle. "Creating an activity" creates an activity, you must create a subclass of activity (or a subclass of an activity subclass). In your subclass, you need to implement a callback method for the system callback, when the activity is converted in various states of its life cycle, such as when activity is created, stopped, restored, or destroyed. The two most important callback methods are: OnCreate () You have to implement this method. The system calls it when creating your activity. In your implementation, you should initialize the basic components of your activity. More importantly, this is where you have to call Setcontentview () to define the activity user interface. The OnPause () system calls this method when the user leaves your activity (though not always means the activity is destroyed).  This is usually when you should submit any changes that will be present beyond the user session (because the user may not be back). There are several other life cycle callback functions that you should use in order to provide a smooth user experience, and a table operation with an abnormal interrupt can cause your activity to be interrupted or even destroyed. 1, implementing a user interface an activity UI is provided by a hierarchical view-inherited from the view class object. Each view controls a specific rectangular area in the activity window and responds to user interaction.  For example, a view might be a button that initializes the action when the user touches it. Android offers a number of predefined view that you can use to design and component your layouts. "Widgets" is a view that provides a visual (and interactive) element to the screen, such as a button, a file field, a check box, or just an image. "Layouts" is a view that inherits from ViewGroup and provides a special layout model for its child view, such as thread layout, grid layout, or dependency layout.  You can subclass the view and ViewGroup classes (or existing subclasses) to create your own widgets and apply them to your activity layout. The most common way is to define a layout using the View plus XML layout file saved in your program resources. In this way, you can maintain your user interface setting individually.Regardless of the code that defines the activity behavior. You can set the layout as UI using Setcontentview (), passing resource ID of resource layout. However, you can also create new views in your activity code and create a view hierarchy by inserting new views into viewgroup and then using that layout by passing to the root ViewGroup to Setcontentview (). A bundle is a mapping: a mapping from a string value to a different package type. Why is a package type, not a numeric type? As you can see in the Put method below, it can also manipulate the bundle itself, and the bundle itself is not a basic numeric type. is a subclass of object. The data transfer between the activity takes on important tasks, the actual delivery is the bundle:


--------------------------------------------------------------------------------------------


Whether the icon is displayed on the phone's interface


3-javaandroid file @override protected void OnCreate (Bundle savedinstancestate) {  super.oncreate (savedinstancestate );  Setcontentview (R.layout.activity_main); Set the View object of the file}4-call <edittext        android:id= "@+id/edittext1"        android:layout_width= "wrap_content"//---- Full content        android:layout_height= "wrap_content"        android:inputtype= "Phone" >        <requestfocus/></ Edittext>


--Focus on the design of button in the interface of--android--layoutfile_parentmatch_parentFill the form<requestfocus/>-----Touch the foot pad pop-up soft keyboard

--The design android:id= "@+id/button1" of the interface in--android--r to add the control---Add the ID number Findviewbyid (R.ID.EDITTEXT1) to the R file;---looking for i D corresponding space--focus--android--design/intent for adding controls in the interface in the startup control: Want to do one thing ==windows start Intent Intent = new Intent ();//Determine if the input is empty if (    Textutils.isempty (NUMMBERSTR)) {}----------------------------Android Click event 1. Create an internal class implementation Onclicklistener interface    Override the OnClick () Method 2. Instantiate the interface, anonymous inner class Bt_dail.setonclicklistener (new Onclicklistener () {callphone ();            }) The 3.MainActivity implementation interface overrides the OnClick () method in the class to execute Callphone () public void OnClick (View v) {switch (V.getid) { Case R.id.bt_cail: ...;            Break        Default: ... break; }} 4. Execute the program internally through the reflection mechanism Android:onclick = "dailbuttonclicked" in mainactivity Main program to add method execution program----source code----1.LAYOUT Layer < Relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Wrap_content "Android: Paddingbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: Context= ". Mainactivity "> <edittext android:id=" @+id/phone_call "android:layout_width=" Match_parent "Android:layout_ height= "Wrap_content" android:layout_alignparentleft= "true" android:layout_alignparenttop= "true" android:ems= "10" Android:inputtype= "Phone" > <requestfocus/> </EditText> <button android:id= "@+id/call_wangqi" Android:layout_width= "Match_parent" android:layout_height= "wrap_content" android:layout_alignleft= "@+id/Call_ Chenyi "android:layout_alignparentbottom=" true "android:text=" @string/call_wan "/> <button android:id=" @+id/ Call_chenyi "android:layout_width=" match_parent "android:layout_height=" wrap_content "android:layout_above=" @+id/ Call_wangqi "android:layout_alignleft=" @+id/call_linyawei "android:text=" @string/call_ta "/> <Button android:id= "@+id/call_linyawei" android:layout_width= "match_parent" android:layout_height= "Wrap_content" Android : layout_above= "@+id/call_chenyi" android:layout_alignleft= "@+id/call_lengzhenfu" android:text= "@string/call_ya"/ > <button android:id= "@+id/call_lengzhenfu" android:layout_width= "match_parent" android:layout_height= "Wrap_ Content "Android:layout_above=" @+id/call_linyawei "android:layout_alignleft=" @+id/call_jinruibin "android:text=" @ String/call_len "/> <button android:id=" @+id/call_jinruibin "android:layout_width=" Match_parent "Android: layout_height= "Wrap_content" android:layout_above= "@+id/call_lengzhenfu" android:layout_alignleft= "@+id/Call_ Chaibo "android:text=" @string/call_jinrui "/> <button android:id=" @+id/call_chaibo "android:layout_width=" Match_parent "android:layout_height=" wrap_content "android:layout_above=" @+id/call_jinruibin "Android:layout_ alignleft= "@+id/call_other" android:text= "@string/call_caibo"/> <textview android:id= "@+id/textVieW2 "Android:layout_width=" Wrap_content "android:layout_height=" wrap_content "android:layout_below=" @+id/Call_ Other "android:layout_centerhorizontal=" true "android:text=" @string/_friend "/> <button android:id=" @+id/Call _other "android:layout_width=" match_parent "android:layout_height=" wrap_content "android:layout_alignleft=" @+id/ Phone_call "android:layout_below=" @+id/phone_call "android:layout_margintop=" 16DP "android:text=" Call_me "/> <button android:id= "@+id/call_xiangshuai" android:layout_width= "match_parent" android:layout_height= "Wrap_ Content "Android:layout_above=" @+id/call_chaibo "android:layout_alignleft=" @+id/call_chaibo "android:text=" @ String/call_x "/> </RelativeLayout>

2-strings<?xml version= "1.0" encoding= "Utf-8"?><resources> <string name= "App_name" >MyFriend</ string> <string name= "action_settings" >Settings</string> <string name= "Hello_world" >myfriend! </string> <string name= "Call_me" >Call_me!</string> <string name= "Call_chaibo" >call_ Chaibo!< /string> <string name= "Call_wangqi" >call_ Wang Qi!</string> <string name= "Call_JINRUIBIN" >call_ 靳瑞斌! </string> <string name= "Call_linyawei" >call_ Lian Yawei!</string> <string name= "Call_lengzhenfu" > Call_ Lengzheng!</string> <string name= "Call_chenyi" >call_ Chen!</string> <string name= "Call_jinrui" & Gt Call_ Shami </string> <string name= "Call_caibo" >call_ Chaibo </string> <string name= "Call_len" >call_ Lengzheng </string> <string name= "Call_ya" >call_ Lian Yawei </string> <string name= "Call_ta" >call_ Cherry </ string> <string name= "Call_wan"; Call_ Wang Qi </string> <string name= "_friend" >\ "friend>.</string> <string name=" call_x ">Call_ Handsome </string></resources>3-mainactivitypackage com.example.myfriend;import Android.net.Uri;import Android.os.bundle;import Android.app.activity;import Android.content.intent;import Android.text.TextUtils;import Android.view.menu;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.Button; Import Android.widget.edittext;import Android.widget.toast;public class Mainactivity extends Activity implements Onclicklistener {private String nummber = ""; @Override protected void OnCreate (Bundle savedinstancestate) {Super.oncrea  Te (savedinstancestate);  Setcontentview (R.layout.activity_main);  Button button1 = (button) Findviewbyid (R.id.call_other);  Button button2 = (button) Findviewbyid (R.id.call_chaibo);  Button Button3 = (button) Findviewbyid (R.id.call_chenyi);  Button Button4 = (button) Findviewbyid (R.id.call_jinruibin); Button button5= (Button) Findviewbyid (R.ID.CALL_LENGZHENFU);  Button Button6 = (button) Findviewbyid (R.id.call_linyawei);  Button button7 = (button) Findviewbyid (R.id.call_wangqi);  Button Button8 = (button) Findviewbyid (R.id.call_xiangshuai);  Button1.setonclicklistener (Mainactivity.this);  Button2.setonclicklistener (Mainactivity.this);  Button3.setonclicklistener (Mainactivity.this);  Button4.setonclicklistener (Mainactivity.this);  Button5.setonclicklistener (Mainactivity.this);  Button6.setonclicklistener (Mainactivity.this);  Button7.setonclicklistener (Mainactivity.this); Button8.setonclicklistener (Mainactivity.this); } @Override Public boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu, this adds items to the action bar if it  is present.  Getmenuinflater (). Inflate (R.menu.main, menu); return true;      } @Override public void OnClick (View v) {//TODO auto-generated Method Stub switch (V.getid ()) {case R.id.call_other:      EditText Text = (EditText) Findviewbyid (R.id.phone_call); ThIs.nummber = Text.gettext (). toString ();      Callphone (This.nummber);   Break    Case r.id.call_chaibo:this.nummber = "656588";    Toast.maketext (Mainactivity.this, "Chaibo" +this.nummber,0). Show ();    Callphone (This.nummber);   Break    Case r.id.call_wangqi:this.nummber = "652008";    Toast.maketext (mainactivity.this, "Wang Qi" +this.nummber,0). Show ();    Callphone (This.nummber);   Break    Case r.id.call_jinruibin:this.nummber = "652019";    Toast.maketext (Mainactivity.this, "Shami" +this.nummber,0). Show ();    Callphone (This.nummber);   Break    Case r.id.call_lengzhenfu:this.nummber = "656181";    Toast.maketext (Mainactivity.this, "Zheng Fu" +this.nummber,0). Show ();    Callphone (This.nummber);   Break    Case r.id.call_linyawei:this.nummber = "656587";    Toast.maketext (Mainactivity.this, "Wei" +this.nummber,0). Show ();    Callphone (This.nummber);   Break    Case R.id.call_chenyi:toast.maketext (Mainactivity.this, "--" +this.nummber,0). Show ();    This.nummber = "652652"; CalLphone (This.nummber);   Break    Case R.id.call_xiangshuai:toast.maketext (Mainactivity.this, "--" +this.nummber,0). Show ();    This.nummber = "656202";    Callphone (This.nummber);   Break  Default:Toast.makeText (Mainactivity.this, "PPP", 0). Show (); }} Private Boolean Callphone (String number) {if (Textutils.isempty (Nummber)) {Toast.maketext (mainactivity.this, "Phone No   Can be empty! ", 0). Show ();  return false;   } Intent Intent = new Intent ();   Intent.setaction (Intent.action_call);   Intent.setdata (Uri.parse ("Tel:" +nummber));   StartActivity (Intent); return true; }}





--Focus on the design of button in the interface of--android--layoutfile_parentmatch_parentFill the form<requestfocus/>-----Touch the foot pad pop-up soft keyboard

android-1-Telephone 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.