这是 scr java 文件 TestingbankaiActivity.java
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class TestingbankaiActivity extends Activity implements OnClickListener {
Button b;
TextView tv;
// Class c,c1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.testingactivity);
initialize();
}
private void initialize() {
// TODO Auto-generated method stub
b = (Button) findViewById(R.id.b1);
tv = (TextView) findViewById(R.id.tvb1);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.b1:
Intent i = new Intent(android.content.Intent.ACTION_DIAL,
Uri.parse("tel:9642777959"));
startActivity(i);
break;
case R.id.tvb1:
Intent i1 = new Intent(android.content.Intent.ACTION_DIAL,
Uri.parse("tel:9642777959"));
startActivity(i1);
break;
}
}
}
this is the xml file .
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/b1"
android:layout_width="70dip"
android:layout_height="70dip"
android:text="hhhh" />
<TextView
android:id="@+id/tvb1"
android:layout_width="50dip"
android:layout_height="50dip"
android:text="hha" />
</LinearLayout>
This is the manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testing.bankai"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".TestingbankaiActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
最后,我得到了带有文本视图和按钮的屏幕。我想要的是,如果用户按下 textview 或按钮,它应该是动作拨号意图。