網(wǎng)站首頁 編程語言 正文
本文實例為大家分享了Android實現(xiàn)注冊界面的具體代碼,供大家參考,具體內(nèi)容如下
LinearLayout 控制布局
TextView 用于顯示文字
EditText 輸入框
RadioGroup 單選按鈕和RadioButton一起用
CheckBox 復選框
Spinner 下拉框
源碼:
register.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ? ? android:orientation="vertical" android:layout_width="match_parent" ? ? android:layout_height="match_parent"> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? > ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:text="用戶名:" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? /> ? ? ? ? <EditText ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:hint="輸入2-10個字符" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? android:layout_weight="1"/> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? > ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:text="密碼: ? ?" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? /> ? ? ? ? <EditText ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:hint="輸入6-10個字符" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? android:layout_weight="1"/> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? > ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="23dp" ? ? ? ? ? ? android:text="性別選擇: ? ?" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? /> ? ? ? ? <RadioGroup ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:layout_marginLeft="10dp" ? ? ? ? ? ? android:layout_marginTop="10dp"> ? ? ? ? ? ? <RadioButton ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:layout_marginLeft="30dp" ? ? ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? ? ? android:text="男"/> ? ? ? ? ? ? <RadioButton ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:layout_marginLeft="30dp" ? ? ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? ? ? android:text="女"/> ? ? ? ? </RadioGroup> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content"> ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="5dp" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:text="愛好選擇:" ? ? ? ? ? ? android:textColor="@color/colorPrimaryDark"/> ? ? ? ? <CheckBox ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="20dp" ? ? ? ? ? ? android:text="游泳"/> ? ? ? ? <CheckBox ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="20dp" ? ? ? ? ? ? android:text="打球"/> ? ? ? ? <CheckBox ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="20dp" ? ? ? ? ? ? android:text="看書"/> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content"> ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="5dp" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:text="所在地"/> ? ? ? ? <Spinner ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="10dp" ? ? ? ? ? ? android:entries="@array/citys"> ? ? ? ? </Spinner> ? ? </LinearLayout> ? ? <Button ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? android:text="注冊" ? ? ? ? android:textColor="@color/colorPrimaryDark"/> </LinearLayout>
strings.xml
<resources> ? ? <string name="app_name">Register</string> ? ? <string-array name="citys"> ? ? ? ? <item>贛州</item> ? ? ? ? <item>上海</item> ? ? ? ? <item>廣州</item> ? ? ? ? <item>深圳</item> ? ? ? ? <item>北京</item> ? ? ? ? <item>湖南</item> ? ? ? ? <item>湖北</item> ? ? ? ? <item>南寧</item> ? ? ? ? <item>廈門</item> ? ? </string-array> </resources>
Main.java
package com.example.hsy.register;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.register);
? ? }
}
效果圖
原文鏈接:https://blog.csdn.net/gh6267/article/details/77853277
相關推薦
- 2022-10-25 如何利用Python和matplotlib更改縱橫坐標刻度顏色_python
- 2023-07-07 Linux服務器zip安裝,及壓縮解壓
- 2022-11-25 Vmware臨時文件存放路徑_VMware
- 2022-05-14 在Pandas?DataFrame中插入一列的方法實例_python
- 2022-01-20 空值判斷運算符 ? ?
- 2022-09-30 Docker容器搭建本地私有倉庫詳情_docker
- 2022-06-12 PostgreSQL聚合函數(shù)的分組排序使用示例_PostgreSQL
- 2022-04-01 k8s報錯:Error response from daemon: pull access deni
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支