<Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"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= "Com.example.phonecall.MainActivity" > <EditTextAndroid:id= "@+id/edittext1"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:layout_alignparenttop= "true"Android:layout_centerhorizontal= "true"Android:inputtype= "Phone" > </EditText> <ButtonAndroid:id= "@+id/button1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignleft= "@+id/edittext1"Android:layout_below= "@+id/edittext1"Android:layout_margintop= "17DP"Android:text= "@string/dail" /></Relativelayout>
@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); //Find buttonButton btn = (button) This. Findviewbyid (R.id.button1); //Tap Event on button monitoringBtn.setonclicklistener (NewCalllistener ()); } Public classCalllistenerImplementsOnclicklistener {@Override Public voidOnClick (View v) {//TODO auto-generated Method Stub//Find textEditText edit = (EditText) mainactivity. This. Findviewbyid (R.ID.EDITTEXT1); //get the content in textString number =Edit.gettext (). toString (); //Translate for IntentIntent Intent =NewIntent (); //set the corresponding action on the intentintent.setaction (Intent.action_call); //CallIntent.setdata (Uri.parse ("Tel:" +Number )); StartActivity (Intent); } }