Android-1-phone dial

Source: Internet
Author: User

Android-1-phone dial


Project package src -- java source code gen folder -- resource file, automatically generated after modification --- R. the drawable class in java corresponds to the drawable directory in the directory, layout corresponds to the layout directory, and String corresponds to the assets folder in the String directory to store large files, such as videos, audios, fonts, etc. (1 GB will not be compiled) res folder --- drawable image Res stores resource files --- layout main. the display content of textView in the layout of the Xm interface cannot be modified --- values String. xml stores strings to facilitate the internationalization of AndroidManifest. xml


2. project Structure parsing src: java source code directory (only one package is allowed) AndroidMainfest. xml (list file, which describes the composition, components, permissions, and other information of an Application) gen/R. java resource file. After modification, the android: Library assets: static resource file drawable program icon layOut folder values: Application String color (String. XML) classes. java Binary Code Compiled by dex: executable files on the Android platform 2. android packaging function. the app provides high-level program models and basic running environment for android. the content class android. the database provides content to browse and publish android. graphics underlying graphics library android. location and Related Services android. media manages audio and video media and interfaces for android.. net. OS provides system services, message transmission, and IPC Mechanisms for android. opengl provides OPENGL tool android. provider: Provides android content for accessing android. telephony provides APL Interaction Related to phone calls. android. view provides a basic user interface framework for android. util involves a tool-Based Method android. webkit default browser interface android. widgets contain various UI elements used in the frequency screen of the application 3. the view Interface view of the core component of the android program. The UI of the component controls the Intent and supports communication between components. Activity: processing interface IntentReceiver receives information and event processing Service background Service Notification: Message and Notification 4. activity declaration cycle void onCreate (Bundle saveInstancestate) void onStart () void onRestart () void onResume () void onPause () void onStop () void onDestroy () myandroid1/res/layout/activity_main.xml
 /Myandroid1/res/values/strings. xml
 
  
Myandroid1
     
 
  
Settings
     
 
  
Jia You Wangqi!
 Activity is an application component that provides a screen for users to interact with each other to complete a task, such as dialing, taking photos, sending emails, and viewing maps. Each activity is given a window where user interfaces can be drawn. The window is usually full of screens, but it can also be smaller than the screen, floating above other windows. An application usually consists of multiple activities, which are usually loosely coupled. Generally, the activity in an application is specified as "main" activity, which is displayed to the user when the application is started for the first time. Each activity can then start another activity to complete different actions. Every time an activity is started, the previous activity stops, but the system keeps the 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. Back Stack complies with the simple "back-to-first-out" principle. Therefore, when the user completes the current activity and then clicks the Back button, the Stack pops up (and is destroyed), and the previous activity is restored. When an activity is stopped because of the startup of a new activity, it is notified that the status changes through the lifecycle callback function of the activity. There are many callback functions that an activity may receive, this is because of its own state changes-whether the system creates it, stops it, restores it, or destroys it-and each callback provides you with the opportunity to complete the specified job that fits this state. For example, when you stop, your activity should release any large objects, such as network database connections. When the activity recovers, you can obtain the necessary resources and resume the interrupted action. These State transformations are part of the lifecycle of an activity. [Creating an Activity] to create an activity, you must create a subclass of the Activity (or a subclass of the Activity ). In your subclass, You need to implement the callback method of the system callback. When the activity changes in multiple States of its lifecycle, for example, when an activity is created, stopped, restored, or destroyed. The two most important callback methods are onCreate (). You must 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, you must call setContentView () to define the activity user interface. The onPause () system calls this method when the user leaves your activity (although it does not always mean that the activity is destroyed ). This is usually because you should submit any changes, which will exists beyond the user session (because the user may not return again ). There are several other lifecycle callback functions that you should use to provide a smooth user experience, and abnormal table operation interruptions may cause your activity to be interrupted or even destroyed. 1. Implementing a user interface the user interface of an activity is provided by a hierarchical View-an object inherited from the View class. Each View Controls a specific rectangular area in the activity window and responds to user interaction. For example, a view may be a button, and Initialization is performed when the user touches it. Android provides a large number of predefined views, which you can use to design and component your layout. "Widgets" is a view that provides visual (and interactive) elements to the screen, such as buttons, file fields, check boxes, or just images. "Layouts" is a View inherited from ViewGroup and provides a special layout model for its subviews, such as thread layout, grid layout, or correlation 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 method is to define a layout. Use view and XML layout files to save them to your program resources. In this way, you can independently maintain your user interface design, but it is irrelevant to the code that defines activity behavior. You can set the layout as the UI using setContentView () to pass the resource ID of the resource layout. However, you can also create a new view in your activity code, and create a view level by inserting the new Views to the ViewGroup, and then pass the layout to the root ViewGroup to setContentView (). Bundle is a ing: A ing from string value to different encapsulation types. Why is it an encapsulation type, not a numerical value? In the following put method, we can see that it can also operate bundle itself. bundle itself is not a basic numerical type. It is a subclass of objects. data transmission between activities bears an important task. Actually, bundle is passed:


Bytes --------------------------------------------------------------------------------------------


Show icons on the mobile phone interface


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHByZSBjbGFzcz0 = "brush: java;"> 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


-- Important abstract -- Android -- the interface in Layout shows that the design of the button file_parent match_parent is full of forms. ----- The keyboard pops up when you touch the mat.

-- Highlights -- Android -- Design of adding controls on the interface in R android: id = "@ + id/button1" --- add the id code findViewById (R. id. editText1); --- find the space corresponding to the ID -- Key abstract -- Android -- start the interface of the control to add the control design // intent: to do one thing = windows start Intent intent = new Intent (); // determine whether the input content is null if (TextUtils. isEmpty (nummberstr) {}---------------------------- android Click Event 1. create an internal class to implement the OnClickListener interface to override onClick () method 2. instantiation interface, anonymous internal class bt_dail.setonClickListener (new OnClickListener () {CallPhone () ;}) 3. the MainActivity implementation interface re-writes 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. android: onClick = "dailButtonClicked" is used internally to execute the program android: onClick = "dailButtonClicked". Add the method execution program to the MainActivity main program ---- source code ---- 1. layOut Layer
  
   
    
   
   
   
   
   
   
   
   
   
   
 

2-Strings
 
     
  
   
MyFriend
      
  
   
Settings
      
  
   
MyFriend!
      
  
   
Call_me!
      
  
   
Call _ Chai Bo!
      
  
   
Call _ Wang Qi!
      
  
   
Call _ Zou ruibin!
      
  
   
Call _ Lian Yawei!
      
  
   
Call _ Leng Zhengfu!
      
  
   
Call _ Chen yiqian!
      
  
   
Call _ Zou ruibin
      
  
   
Call _ Chai Bo
      
  
   
Call _ Leng Zhengfu
      
  
   
Call _ Lian Yawei
      
  
   
Call _ Tang Tao
      
  
   
Call _ Wang Qi
      
  
   
\ "Friend>.
      
  
   
Call _ xiangshuai
  
 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. onCreate (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) findViewB YId (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. thi S); 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, "Chai Bo" + 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, "Yan ruibin" + 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, "Yawei" + 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. th Is, "-->" + 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, "the phone number cannot be blank! ", 0 ). show (); return false;} Intent intent = new Intent (); intent. setAction (Intent. ACTION_CALL); intent. setData (Uri. parse ("tel:" + nummber); startActivity (intent); return true ;}}





-- Important abstract -- Android -- the interface in Layout shows that the design of the button file_parent match_parent is full of forms. ----- The keyboard pops up when you touch the mat.

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.