Android4每日一例--第一天
HelloWorld Helloworld,java import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class HelloWorld extends Activity { //当第一次创建该Activity时回调该方法 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置使用main.xml文件定义的页面布局 setContentView(R.layout.main); //获取UI界面中ID为R.id.ok的按钮 Button bn = (Button)findViewById(R.id.ok); //为按钮绑定一个单击事件的易做图 bn.setOnClickListener(new OnClickListener(){ public void onClick(View v) { //获取UI界面中ID为R.id.show的文本框 final TextView show = (TextView)findViewById(R.id.show); //改变文本框的文本内容 show.setText("Hello Android~" + new java.util.Date()); } }); } } 点击按钮后文本框显示Hello Android加当前时间。 自动生成的R文件, public final class R { public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; } public static final class id { public static final int ok=0x7f050001; public static final int show=0x7f050000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int app_name=0x7f040000; } }
补充:移动开发 , Android ,