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. editT Ext; 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 present. 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 AndroidManifest.xml.int id = item. getItemId (); if (id = R. id. action_settings) {r Eturn true;} return super. onOptionsItemSelected (item);}/*** A placeholder fragment containing a simple view. A placeholder segment contains a simple view. * // *** This internal class is automatically completed by the latest development tool. Its function is to load and parse the fragment_main.xml file and obtain fragment_main. * registered components in xml. ** @ author Martin **/public static class extends Fragment {public PlaceholderFragment () {}@ Overridepublic View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {// obtain the View object according to the final View rootView = inflater in the fragment_main.xml file. inflate (R. layout. fragment_main, container, false); // obtain the component Button dialBtn = (Button) rootView through the view object. findViewById (R. id. btn_dial); System. out. println (rootView. findViewById (R. id. btn_dial) + "==============" + R. id. btn_dial + "==========================" + dialBtn ); // Add events for components // since I am also a newbie, I have not solved the problem of how to obtain components without using anonymous internal classes, dialBtn. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stub // obtain the component EditText et_number = (EditText) rootView through the View object. 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 ;}}}