这是xml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >     <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="拨号" />
     <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="0"
        >         <TableRow>             <EditText
                 android:id="@+id/edt"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:layout_alignParentLeft="true"
                 android:layout_below="@+id/textView1"
                 android:layout_marginBottom="80px"
                 android:ems="10"
                 android:hint="输入号码" >                 <requestFocus />
             </EditText>             <Button
                 android:id="@+id/del"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="删除"
                 android:textSize="20px" />
         </TableRow>
 
    </TableLayout> 
    
        <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="0,1,2"
        >
        
        <TableRow>
            <Button 
                android:id="@+id/bt1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="3"
                android:textSize="40px" />
            </TableRow>
        <TableRow >
            <Button 
                android:id="@+id/bt4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="4"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="5"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="6"
                android:textSize="40px" />
        </TableRow>
        <TableRow >
            <Button 
                android:id="@+id/bt7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="7"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="8"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="9"
                android:textSize="40px" />
        </TableRow>
        <TableRow >
            <Button 
                android:id="@+id/bt10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="*"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0"
                android:textSize="40px" />
            <Button 
                android:id="@+id/bt11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="#"
                android:textSize="40px" />
        </TableRow>
       
        
    </TableLayout></LinearLayout>
这是java文件package com.example.phonecall;import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;public class MainActivity extends Activity {
private String[] ids={"bt1","bt2","bt3","bt4","bt5","bt6","bt7","bt8","bt9","bt10","bt0","bt11"};
private String string1=null;
private EditText edt2; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edt2=(EditText)findViewById(R.id.edt);

int[] ia=new int[ids.length];
for(int i=0;i<ids.length;i++){
   ia[i]=Integer.parseInt(ids[i]);
}

for(int i=0;i<ia.length;i++){
Button bb=new Button(this);
bb=(Button)findViewById(ia[1]);
bb.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
Button aa=(Button)findViewById(v.getId());
edt2.setText(string1+aa.getText());

}
});
}
} @Override
public 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;
}}