android按钮的操作例子,简单大家看明白_基础篇



先让我们看一下图先。

 

 

 

 

代码
主代码量,很少吧。大家一下,就明白。哈哈,

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView myTextView
= (TextView) findViewById(R.id.myTextView);
Button myButton
= (Button) findViewById(R.id.myButton);// 取得按扭的内容
myTextView.setText("我的第一个TextView");// 请注意显示的时候在哪里。
myButton.setText("我的第一个Button" + "\n" + "Smart测试程序");// 按扭换行了吧。另外大家在看的时候,请注意一下
// ,main.xml文件与strings.xml写法。
}

 

posted on 2011-01-30 20:07  llb988  阅读(300)  评论(0编辑  收藏  举报

导航