Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android游戏开发系统控件-Button

Android游戏开发系统控件-ButtonButton(按钮)是一个常用的系统小组件,很小但是在开发中最常用到。一般通过与监听器使用,从而触发一些特定事件。下面为一个Andriod项目“ButtonProject”,对应的代码如下项目功能:点击按钮触发事件代码分别为:main.xmlstring.xmlButtonProject.java项目运行效果图:代码清单:=》》main.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <TextView  
  8.         android:id="@+id/tv"  
  9.         android:layout_width="fill_parent"  
  10.         android:layout_height="wrap_content"  
  11.         android:text="@string/hello" />  
  12.     <Button   
  13.         android:id="@+id/btn_ok"  
  14.         android:layout_width="fill_parent"  
  15.         android:layout_height="wrap_content"  
  16.         android:text="@string/btn_ok"  
  17.         />  
  18.     <Button  
  19.         android:id="@+id/btn_cancel"  
  20.         android:layout_width="fill_parent"  
  21.         android:layout_height="wrap_content"  
  22.         android:text="@string/btn_cancel"  
  23.         />  
  24.   
  25. </LinearLayout>