#2
wjz11172013-09-22 15:35
|
大侠们, 帮忙看下怎么个情况?
好人有好报阿~
-----------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/input" />
<EditText
android:id="@+id/num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/haha" />
</LinearLayout>
-------------------------------------------------------------------------------
public class MainActivity extends Activity {
private EditText txt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txt= (EditText) this.findViewById(R.id.num);
Button button = (Button) this.findViewById(R.id.button);
button.setOnClickListener(new ButtonClick());
}
private final class ButtonClick implements View.OnClickListener {
@Override
public void onClick(View v) {
Intent intent=new Intent();
String numString=txt.toString();
intent.setAction("android.intent.action.CALL");//設置意圖
//intent.addCategory("android.intent.category.DEFAULT");//設置類別
intent.setData(Uri.parse("tel:"+numString));//傳入用戶輸入的號碼
System.out.println(txt.toString());
startActivity(intent);//方法內部會自動為intent添加類別:amdroid.intent.category.DEFAULT
}
}
-----------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.
package="my.phone"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.CALL_PHONE"/>
</manifest>