Package Com.dhy.phonedial;import Android.app.activity;import Android.app.fragment;import android.content.Intent; Import Android.net.uri;import android.os.bundle;import Android.view.layoutinflater;import Android.view.Menu;import Android.view.menuitem;import Android.view.view;import Android.view.view.onclicklistener;import Android.view.viewgroup;import Android.widget.button;import Android.widget.edittext;public class MainActivity Extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); if (savedinstancestate = = null) {Getfragmentmanager (). BeginTransaction (). Add (R.id.container, New Placeholderfragment ()). commit ();}} @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is PR Esent.getmenuinflater (). Inflate (R.menu.main, menu); return true;} @Overridepublic boolean onoptionsitemselected (MenuItem Item) {//Handle Action Bar item clicks here. The action bar will//automatically handle clicks on the Home/up button so long//as you specify a parent activity in and RoidManifest.xml.int id = item.getitemid (); if (id = = r.id.action_settings) {return true;} return super.onoptionsitemselected (item);} /** * A placeholder fragment containing a simple view. A placeholder fragment contains a simple view. *//** * This internal class is the latest development tool automatically completed, its function is to load and parse the Fragment_main.xml file, you can get fragment_main. * Registered components in XML. * * @author Martin * */public static class Placeholderfragment extends Fragment {public placeholderfragment () {} @Overrid Epublic View Oncreateview (Layoutinflater inflater, ViewGroup container,bundle savedinstancestate) {//Get View object according to fragment _main.xml file Final View Rootview = Inflater.inflate (R.layout.fragment_main,container, false);//Get Component button from view object DIALBTN = (Button) Rootview.findviewbyid (r.id.btn_dial); System.out.println (Rootview.findviewbyid (r.id.btn_dial) + "============" + r.id.btn_dial + "===================" + DIALBTN);//Add an event for a component//Because I'm also a beginner. The problem of how to get components without using anonymous inner classes is not resolved, DIALBTN.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method stub//Same Gets the component through the View object EditText Et_number = (EditText) Rootview.findviewbyid (R.id.edit_number); String number = Et_number.gettext (). toString (); System.out.println ("================" + number), Intent Intent = new Intent (); intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ("Tel:" + number)); StartActivity (intent);}); return Rootview;}}}