I. Interface Design (not designed at all)
An editview and a button are displayed on the right:
<RelativeLayout xmlns: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" tools:context=".MainActivity" > <EditText android:id="@+id/phoneNo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="49dp" android:ems="10" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/mobile" android:layout_alignRight="@+id/mobile" android:layout_below="@+id/mobile" android:layout_marginTop="50dp" android:text="call" /></RelativeLayout>
Ii. Code Implementation
Mainactivity. Java
Button. setonclicklistener (new view. onclicklistener () {@ overridepublic void onclick (view v) {// todo auto-generated method stubphonetext = (edittext) findviewbyid (R. id. phoneno); string phoneno = phonetext. gettext (). tostring (); If (phoneno = NULL | "". equals (phoneno. trim () {toast. maketext (getapplicationcontext (), "no phone number", toast. length_short ). show ();} else {toast. maketext (getapplicationcontext (), "with phone number" + phoneno, toast. length_short ). show (); intent = new intent (intent. action_call, Uri. parse ("Tel:" + phoneno); startactivity (intent );}}});