1、在layout中的xml文件添加控件
如:
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/app_tranData" />
其中,button1为控件的id
2、在代码中,可通过下面代码获取到控件。
Button button=(Button)this.findViewById(R.id.button1);
其中:button1为步骤1中的button1的id