乐读文学

Android从入门到精通

乐读文学 > 科普学习 > Android从入门到精通

第175页

书籍名:《Android从入门到精通》    作者:明日科技




android:text="类  别:"



android:layout_height="wrap_content"



android:layout_alignBaseline="@+id/spInType"



android:layout_alignBottom="@+id/spInType"



android:layout_alignLeft="@+id/tvInTime">










android:layout_width="210dp"



android:layout_height="wrap_content"



android:layout_toRightOf="@id/tvInType"



android:layout_below="@id/txtInTime"



android:entries="@array/intype"



/>






android:id="@+id/tvInHandler"



android:textSize="20sp"



android:text="付款方:"



android:layout_height="wrap_content"



android:layout_alignBaseline="@+id/txtInHandler"



android:layout_alignBottom="@+id/txtInHandler"



android:layout_toLeftOf="@+id/spInType">










android:id="@+id/txtInHandler"



android:layout_width="210dp"



android:layout_height="wrap_content"



android:layout_toRightOf="@id/tvInHandler"



android:layout_below="@id/spInType"



android:singleLine="false"



/>






android:id="@+id/tvInMark"



android:textSize="20sp"



android:text="备  注:"



android:layout_height="wrap_content"



android:layout_alignTop="@+id/txtInMark"



android:layout_toLeftOf="@+id/txtInHandler">










android:id="@+id/txtInMark"



android:layout_width="210dp"



android:layout_height="150dp"



android:layout_toRightOf="@id/tvInMark"



android:layout_below="@id/txtInHandler"



android:gravity="top"



android:singleLine="false"



/>














android:orientation="vertical"



android:layout_width="fill_parent"



android:layout_height="fill_parent"



android:layout_weight="3"



>






android:layout_height="fill_parent"



android:padding="10dp"



>






android:id="@+id/btnInCancel"



android:layout_width="80dp"



android:layout_height="wrap_content"



android:layout_alignParentRight="true"



android:layout_marginLeft="10dp"



android:text="取消"



/>






android:id="@+id/btnInSave"



android:layout_width="80dp"



android:layout_height="wrap_content"



android:layout_toLeftOf="@id/btnInCancel"



android:text="保存"



/>













15.10.2 设置收入时间

在com.xiaoke.accountsoft.activity包中创建一个AddInaccount.java文件,该文件的布局文件设置为addinaccount.xml。在AddInaccount.java文件中,首先创建类中需要用到的全局对象及变量,代码如下:

protected  static  final  int  DATE_DIALOG_ID  =  0;  //创建日期对话框常量



EditText  txtInMoney,txtInTime,txtInHandler,txtInMark;  //创建4个EditText对象



Spinner  spInType;  //创建Spinner对象



Button  btnInSaveButton;  //创建Button对象“保存”



Button  btnInCancelButton;  //创建Button对象“取消”



private  int  mYear;  //年



private  int  mMonth;  //月



private  int  mDay;  //日

在onCreate()覆写方法中,初始化创建的EditText、Spinner和Button对象,代码如下:

txtInMoney=(EditText)  findViewById(R.id.txtInMoney);  //获取“金额”文本框



txtInTime=(EditText)  findViewById(R.id.txtInTime);  //获取“时间”文本框