初步用户注册页面
来源:互联网 发布:淘宝客软件下载 编辑:程序博客网 时间:2024/06/09 23:03
注册页面千变万化,但基本信息也就那么几项。这里只是对于常用的一些信息注册做了小小的编译,可以在android上运行哦!
首先,填写一下自己的基本信息,如图:
一 布局:
layout中的activity_main.xml中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg" android:orientation="vertical" > <TextView android:id="@+id/nameinput1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/nameinput1" tools:context=".MainActivity" /> <EditText android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:id="@+id/nameinput2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/nameinput2" tools:context=".MainActivity" /> <RadioButton android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/radioButton1" /> <RadioButton android:id="@+id/radioButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/radioButton2" /> <TextView android:id="@+id/nameinput3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/nameinput3" tools:context=".MainActivity" /> <DatePicker android:id="@+id/datePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="14dp" /> <TextView android:id="@+id/nameinput4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/nameinput4" tools:context=".MainActivity" /> <CheckBox android:id="@+id/checkBox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/checkBox1" /> <CheckBox android:id="@+id/checkBox2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/checkBox2" /> <Button android:id="@+id/click" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/clickbutton" /></LinearLayout>
布局的同时还需对里面出现的变量进行定义:
strings.xml
<resources> <string name="app_name">用户注册页面</string> <string name="nameinput1">请输入你的姓名:</string> <string name="nameinput2">请输入你的性别:</string> <string name="radioButton1">男</string> <string name="radioButton2">女</string> <string name="nameinput3">请输入你的生日:</string> <string name="nameinput4">请输入你的兴趣爱好:</string> <string name="checkBox1">唱歌</string> <string name="checkBox2">看电影</string> <string name="clickbutton">提交</string> <string name="menu_settings">Settings</string> <string name="title_activity_main">用户注册页面</string> <string name="title_activity_show">ShowActivity</string></resources>
最重要的要数实现功能的activity了,好比“布局是面子,方法是里子。”只有布局没方法,是运行不起来的。现在就看我的了:
package w3.dyp.document;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.*;public class MainActivity extends Activity {private EditText nameInput1;private EditText nameInput2;private EditText nameInput3;private EditText nameInput4;public EditText getNameInput1() {return nameInput1;}public EditText getNameInput2() {return nameInput2;}public EditText getNameInput3() {return nameInput3;}public EditText getNameInput4() {return nameInput4;}private RadioButton radioButton1;private RadioButton radioButton2;private Button clickbutton;private CheckBox checkBox1;private CheckBox checkBox2;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);nameInput1 = (EditText) this.findViewById(R.id.name);clickbutton = (Button) this.findViewById(R.id.click);clickbutton.setOnClickListener(new OnClickListener() {public void onClick(View v) {String name = nameInput1.getText().toString();Toast.makeText(MainActivity.this, "你好" + name+"你已经成功注册",Toast.LENGTH_LONG).show();}});}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {getMenuInflater().inflate(R.menu.activity_main, menu);return true;}}
划线的地方还可以经过修改,进行信息的完善显示
对于里面的信息通过填写,选择进行确定:
点击“确定”就能成功注册,显示注册成功的对话框。
弹出注册成功的对话框可以通过添加showactivity文件完成,这里就不多说了。
经过和老师的效果图对比发现日期的格式不一样:
这只是日期格式的问题,选择时选择中文格式的就可以。
- 初步用户注册页面
- 初步用户注册页面(更新)
- 初步用户注册页面(完结)
- 设计用户注册页面
- 用户注册页面设计
- H5 用户注册页面
- 用户注册页面
- 如何制作用户注册页面
- bbs用户注册页面源码
- 用户注册页面<城市级联>
- 用户注册页面的实现
- 注册一个用户控件到aspx页面
- Drupal 6 自定义用户登陆、注册页面
- 用户注册页面--ajax.php.js.css
- WordPress自定义用户注册页面插件
- 一个简单的用户注册页面
- HTML简单的用户注册页面
- JSP用户注册登陆注销JSP页面
- Java IO详解(两种设计模式的分析)
- (第Ⅳ部分 行为型模式篇) 第18章 观察者模式(Oberver Pattern)
- Service: 生命周期与 startService
- Windows下的Memcache安装
- Jexus web server v5.1 正式发布
- 初步用户注册页面
- Xcode4默认提供项目模板
- libx264是干什么的?
- Android获取屏幕分辨率 dp pix转换
- MongoDB与PHP -- Shell命令
- 给定先序:ABCDEFGHIJK 给定中序:CBEDGFAHJIK 首先分析上述给定的先,中序,首先得知先序遍历的肯定是二叉树的根节点:A,在看中序遍历,根据中序遍历的原理可知,在A左边的一定全部属于
- cocos2d-x触摸事件优先级的探究与实践
- 基于注释的Spring Security实战指南
- 内存数据库内核开发工作日志(初稿)(一)