SuperbookKing

5.用户接口UI布局----View控件的概述之Button
Button(textview 子类)----控件能向用户展现文本信息
// With text
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_text"
... />
// With an icon ( ImageView 子类)
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button_icon" ... />
// With text and an icon
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_text"
android:drawableLeft="@drawable/button_icon" ... />
android:onClick="sendMessage"
publicvoid sendMessage(View view){
// Do something in response to button click
}
sendMessage 应该满足
  • Be public
  • Return void
  • Define a View as its only parameter (this will be the View that was clicked)
 
 

posted on 2012-07-21 19:43  SuperbookKing  阅读(155)  评论(0)    收藏  举报