ViewFlipper 中的 LinearLayouts 作为不同的活动
我正在使用 ViewFlipper 在不同视图之间导航(来自 LinearLayouts)。每个视图都是一种表单,在每个视图中我想验证我的数据表单。我无法在视图翻转器中正确实现验证。
我的 xml 文件如下:
<LinearLayout
android:background="#6B8AAD"
android:layout_margin="3dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.80">
<ViewFlipper
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/view1" android:id="@+id/view1" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<include layout="@layout/view2" android:id="@+id/view2" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<include layout="@layout/view3" android:id="@+id/view3" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<include layout="@layout/view4" android:id="@+id/view4" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</ViewFlipper>
</LinearLayout>
---------------------view1 xml 其余部分是相同的。------------ ------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#6B8AAD"
android:weightSum="0.70">
<TextView
android:text="Citizenship Certificate No."
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtCitizenshipCertificateNo"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="District"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/spinnerDistrict"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:text="Date of Issue of Identity Card"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtDateOfIssueOfIdentityCardForNonDisabled"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="Father's Name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtFatherName"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="Mother's Name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtMotherName"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
我的问题是验证此表单数据。 我在最后一个视图中有一个菜单,用于预览输入数据。 如果此表单或其他形式的任何视图未填写,我希望向用户显示该视图/表单。 如果我可以将每个视图用作一项活动,那么我就可以完成验证。但我有一个单一的活动,我的代码行已经在 2000 左右。我希望通过我的代码的模块化来完成。 请引导我走向正确的方向。
I am using a ViewFlipper to navigate between different views(from LinearLayouts). Each Views is a kind of Form and in each view i want to validate my data forms. I have not been able to achieve validations properly within the viewflipper.
My xml file is as:
<LinearLayout
android:background="#6B8AAD"
android:layout_margin="3dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.80">
<ViewFlipper
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/view1" android:id="@+id/view1" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<include layout="@layout/view2" android:id="@+id/view2" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<include layout="@layout/view3" android:id="@+id/view3" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<include layout="@layout/view4" android:id="@+id/view4" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</ViewFlipper>
</LinearLayout>
---------------------view1 xml and the rest are some kind of same.------------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#6B8AAD"
android:weightSum="0.70">
<TextView
android:text="Citizenship Certificate No."
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtCitizenshipCertificateNo"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="District"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/spinnerDistrict"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:text="Date of Issue of Identity Card"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtDateOfIssueOfIdentityCardForNonDisabled"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="Father's Name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtFatherName"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="Mother's Name"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/txtMotherName"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
My Problem is on validating this form data.
I have a menu at my last view which is to preview the input data.
If this form or other form of any views are not filled i wish to show that view/form to user.
If i could use each view as an activity then i could have done the validation. But I have single activity where my lines of code has already been aroubnd 2000. I wish to accomplish with modularity in my code.
Please guide me to the right direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论