The dialer is a very simple layout, the best way to get started with Android.
This program gives Android API19 compile implementation, so is the new layout. Please note that you are not used to it.
Next time I'll be free to fill up.
1. Java Main program:
Public classMainactivityextendsactionbaractivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); if(Savedinstancestate = =NULL) {Getsupportfragmentmanager (). BeginTransaction (). Add (R.id.container,Newplaceholderfragment ()). commit (); } } Public voidCall (View v) {System.out.println ("Make a phone call. "); //Read numberEditText edittext=(EditText) Findviewbyid (r.id.eal); String String=Edittext.gettext (). toString (); //dialingIntent intent=NewIntent (); Intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ("Tel:" +string)); StartActivity (Intent); } @Override Public BooleanOncreateoptionsmenu (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 Booleanonoptionsitemselected (MenuItem item) {//Handle Action Bar item clicks here. The Action Bar would//automatically handle clicks on the Home/up button, so long//As you specify a the parent activity in Androidmanifest.xml. intID =Item.getitemid (); if(id = =r.id.action_settings) { return true; } return Super. onoptionsitemselected (item); } /*** A placeholder fragment containing a simple view. */ Public Static classPlaceholderfragmentextendsFragment { Publicplaceholderfragment () {} @Override PublicView Oncreateview (layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { View Rootview= Inflater.inflate (R.layout.fragment_main, container,false); returnRootview; } }}
2. Main list
<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.caller"Android:versioncode= "1"Android:versionname= "1.0" > <USES-SDKandroid:minsdkversion= "9"android:targetsdkversion= "+" /> <uses-permissionAndroid:name= "Android.permission.CALL_PHONE" /> <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" > <ActivityAndroid:name= "Com.example.caller.MainActivity"Android:label= "@string/app_name" > <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> </Application></Manifest>
3. Layout List main activity
<xmlns:android= "http://schemas.android.com/apk/res/android" xmlns: Tools= "Http://schemas.android.com/tools" android:id= "@+id/container" Android:layout_width = "Match_parent" android:layout_height= "Match_parent" tools:context= " Com.example.caller.MainActivity " tools:ignore=" Mergerootframe "/>
4. layout file
<Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"><TextViewAndroid:id= "@+id/cal"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "@string/cal" /><EditTextAndroid:id= "@+id/eal"Android:inputtype= "Number"Android:layout_below= "@+id/cal"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content" /><ButtonAndroid:id= "@+id/bal"Android:onclick= "Call"Android:layout_below= "@+id/eal"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "@string/bal" /></Relativelayout>