把你的xml贴出来看看嘛!
我给你在网上找了个参考的xml文件咯:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView 
android:id="@+id/show_TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:id="@+id/Click_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击"
/>
</LinearLayout>程序的定义如下:public class ButtonMainActivity extends Activity
{    private TextView show;
    private Button press;
    /** Called when the activity is first created. */
    @Override
    public void onCreate( Bundle icicle )
    {
        super.onCreate( icicle );
        // ToDo add your GUI initialization code here
        //获取TextView 和Button 资源
        this.setContentView( R.layout.main );        
        this.show = ( TextView ) findViewById( R.id.show_TextView );
        this.press = ( Button ) findViewById( R.id.Click_Button );        //给Button 添加事件监听器Button.OnClickListener()
        press.setOnClickListener( new Button.OnClickListener()
        {            @Override
            public void onClick( View v )
            {
                // TODO Auto-generated method stub
            }
        } );
        //处理事件
        press.setOnClickListener( new Button.OnClickListener()
        {            @Override
            public void onClick( View v )
            {
                show.setText( "Hi , Google Android!" );
            }
        } );
    }
}
//如果你在xml修改了控件的名称(show_TextView改成show)的话,代码就要改成你修改后的名字show;
this.show = ( TextView ) findViewById( R.id.show_TextView );
=>this.show = ( TextView ) findViewById( R.id.show);
对应修改后的xml如下:
<TextView 
android:id="@+id/show"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
//如果你在xml修改了控件的类型(TextView改成Button)的话,代码就要改成你修改后的类型呢
this.show = ( TextView ) findViewById( R.id.show_TextView );
=>this.show = ( Button) findViewById( R.id.show_TextView );
对应修改后的xml如下:
<Button
android:id="@+id/show_TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>