最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實現(xiàn)登錄界面的注冊功能

 更新時間:2022年04月23日 17:12:43   作者:DY.memory  
這篇文章主要為大家詳細介紹了Android實現(xiàn)登錄界面的注冊功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android登錄界面的注冊實現(xiàn)代碼,供大家參考,具體內(nèi)容如下

注冊一個登錄界面在控制臺將輸入的信息文本選框展示出來

xml界面設計(前面已發(fā))

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? xmlns:app="http://schemas.android.com/apk/res-auto"
? ? xmlns:tools="http://schemas.android.com/tools"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? tools:context=".MainActivity"
? ? android:orientation="vertical"
?
? ? >
? ? <TextView
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:text="注冊"
? ? ? ? android:textSize="35sp"
? ? ? ? android:gravity="center"
? ? ? ? android:background="#FF5722"
? ? ? ? />
<LinearLayout
? ? android:layout_width="wrap_content"
? ? android:layout_height="210dp"
? ? android:orientation="horizontal"
? ? >
?<Button
? ? ?android:layout_width="wrap_content"
? ? ?android:layout_height="wrap_content"
? ? ?android:background="@drawable/qq"
? ? ?android:layout_weight="1"
? ? ?android:text="用QQ注冊"
? ? ?android:gravity="center"
? ? ?android:textSize="20sp"
? ? ?/>
? ? <Button
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="210dp"
? ? ? ? android:background="@drawable/wechat"
? ? ? ? android:layout_weight="1"
? ? ? ? android:text="用微信注冊"
? ? ? ? android:textSize="20sp"
? ? ? ? />
</LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:orientation="horizontal"
? ? ? ? >
? ? ? ? <ImageView
? ? ? ? ? ? android:id="@+id/yxlg"
? ? ? ? ? ? android:layout_marginTop="12dp"
? ? ? ? ? ? android:layout_marginLeft="80dp"
? ? ? ? ? ? android:layout_width="30dp"
? ? ? ? ? ? android:layout_height="30dp"
? ? ? ? ? ? android:background="@drawable/net"
? ? ? ? ? ? />
? ?<TextView
? ? ? ?android:paddingTop="5dp"
? ? ? ?android:paddingBottom="5dp"
? ? ? ?android:id="@+id/yxld"
? ? ? ?android:layout_width="match_parent"
? ? ? ?android:layout_height="wrap_content"
? ? ? ?android:text=" ? 用郵箱登錄"
? ? ? ?android:gravity="center"
? ? ? ?android:textSize="35sp"
? ? ? ?/>
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="1dp"
? ? ? ? android:background="@color/colorAccent"
? ? ? ? >
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:orientation="horizontal">
? ? <TextView
? ? ? ? android:paddingTop="12dp"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="60dp"
? ? ? ? android:text="名字:"
? ? ? ? android:gravity="left"
? ? ? ? android:textSize="25sp"
? ? ? ? />
? ? <EditText
? ? ? ? android:id="@+id/mz"
? ? ? ? android:paddingTop="12dp"
? ? ? ? android:background="@null"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:textSize="30sp"
?
? ? ? ? />
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="1dp"
? ? ? ? android:background="@color/colorAccent"
? ? ? ? >
</LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:orientation="horizontal">
? ? ? ? <TextView
? ? ? ? ? ? android:paddingTop="12dp"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="60dp"
? ? ? ? ? ? android:text="賬號:"
? ? ? ? ? ? android:gravity="left"
? ? ? ? ? ? android:textSize="25sp"
? ? ? ? ? ? />
? ? ? ? <EditText
? ? ? ? ? ? android:id="@+id/zh"
? ? ? ? ? ? android:paddingTop="12dp"
? ? ? ? ? ? android:background="@null"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:textSize="30sp"
? ? ? ? ? ? />
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="1dp"
? ? ? ? android:background="@color/colorAccent"
? ? ? ? >
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:orientation="horizontal">
? ? ? ? <TextView
? ? ? ? ? ? android:paddingTop="12dp"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="60dp"
? ? ? ? ? ? android:text="密碼:"
? ? ? ? ? ? android:gravity="left"
? ? ? ? ? ? android:textSize="25sp"
? ? ? ? ? ? />
? ? ? ? <EditText
? ? ? ? ? ? android:password="true"
? ? ? ? ? ? android:id="@+id/mm"
? ? ? ? ? ? android:paddingTop="12dp"
? ? ? ? ? ? android:background="@null"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:textSize="30sp"
? ? ? ? ? ? />
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="1dp"
? ? ? ? android:background="@color/colorAccent"
? ? ? ? >
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:orientation="horizontal">
? ? ? ? <TextView
? ? ? ? ? ? android:paddingTop="12dp"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="60dp"
? ? ? ? ? ? android:text="性別: ? ? ? ?"
? ? ? ? ? ? android:gravity="left"
? ? ? ? ? ? android:textSize="25sp"
? ? ? ? ? ? />
? ? ? ? <RadioGroup
? ? ? ? ? ? android:id="@+id/xb"
? ? ? ? ? ? android:layout_marginTop="15dp"
? ? ? ? ? ? android:orientation="horizontal"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="wrap_content">
? ? ? ? <RadioButton
? ? ? ? ? ? android:id="@+id/nan"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:text="男"
? ? ? ? ? ? android:textSize="20sp"
? ? ? ? ? ? />
<RadioButton
? ? android:id="@+id/nu"
? ? android:layout_width="wrap_content"
? ? android:layout_height="wrap_content"
? ? android:text="女"
? ? android:textSize="20sp"
? ? />
? ? ? ? </RadioGroup>
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="1dp"
? ? ? ? android:background="@color/colorAccent"
? ? ? ? >
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:orientation="horizontal">
? ? ? ? <TextView
? ? ? ? ? ? android:paddingTop="12dp"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="60dp"
? ? ? ? ? ? android:text="選擇你的愛好:"
? ? ? ? ? ? android:gravity="left"
? ? ? ? ? ? android:textSize="25sp"
? ? ? ? ? ? />
? ? ? ? <CheckBox
? ? ? ? android:id="@+id/cg"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:text="唱歌"
? ? ? ? android:textSize="20sp" />
? ? ? ? <CheckBox
? ? ? ? ? ? android:id="@+id/tw"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:text="跳舞"
? ? ? ? ? ? android:textSize="20sp" />
? ? ? ? <CheckBox
? ? ? ? ? ? android:id="@+id/ds"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:text="讀書"
? ? ? ? ? ? android:textSize="20sp" />
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="1dp"
? ? ? ? android:background="@color/colorAccent"
? ? ? ? >
? ? </LinearLayout>
? ? <Button
? ? ? ? android:id="@+id/btn1"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="100dp"
? ? ? ? android:text="提交"
? ? ? ? android:textSize="30sp"
? ? ? ? />
</LinearLayout>

注冊功能實現(xiàn)

package com.example.registerlogin;
?
import androidx.appcompat.app.AppCompatActivity;
?
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Toast;
?
?
public class MainActivity extends AppCompatActivity implements View.OnClickListener,CompoundButton.OnCheckedChangeListener{
private EditText mz,zh,mm;
private Button btn1;
private String name,id,pwd,sex,hobby;
private RadioGroup xb;
private CheckBox cg,tw,ds;
?
?
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_main);
? ? ? ? btn1=findViewById(R.id.btn1);
? ? ? ? mz=findViewById(R.id.mz);
? ? ? ? zh=findViewById(R.id.mz);
? ? ? ? mm=findViewById(R.id.mz);
? ? ? ? cg=findViewById(R.id.cg);
? ? ? ? tw=findViewById(R.id.tw);
? ? ? ? ds=findViewById(R.id.ds);
? ? ? ? xb=findViewById(R.id.xb);
?
? ? ? ? btn1.setOnClickListener(MainActivity.this);
? ? ? ? xb.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
? ? ? ? ? ? ? ? {switch (checkedId){
? ? ? ? ? ? ? ? ? ? case R.id.nan:
? ? ? ? ? ? ? ? ? ? sex = "男";
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? case R.id.nu:
? ? ? ? ? ? ? ? ? ? sex="女";
? ? ? ? ? ? ? ? ? ? break;
?
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? });
? ? }
? ? private void getData(){
? ? ? ? name=mz.getText().toString().trim();
? ? ? ? id=zh.getText().toString().trim();
? ? ? ? pwd=mm.getText().toString().trim();
? ? }
? ? ?public void onClick(View v) {
? ? ? ? ?switch (v.getId()) {
? ? ? ? ? ? ?case R.id.btn1:
? ? ? ? ? ? ? ? ?getData();
?
? ? ? ? ? ? ? ? ?if (TextUtils.isEmpty(name)) {
?
? ? ? ? ? ? ? ? ? ? ?Toast.makeText(MainActivity.this, "請輸入名字", Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? ?} else if (TextUtils.isEmpty(id)) {
?
? ? ? ? ? ? ? ? ? ? ?Toast.makeText(MainActivity.this, "請輸入賬號", Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? ?} else if (TextUtils.isEmpty(pwd)) {
?
? ? ? ? ? ? ? ? ? ? ?Toast.makeText(MainActivity.this, "請輸入密碼", Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? ?} else if (TextUtils.isEmpty(sex)) {
?
? ? ? ? ? ? ? ? ? ? ?Toast.makeText(MainActivity.this, "請輸入性別", Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? ?}else if (TextUtils.isEmpty(hobby)) {
?
? ? ? ? ? ? ? ? ? ? ?Toast.makeText(MainActivity.this, "請輸入愛好", Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? ?}else {
? ? ? ? ? ? ? ? ? ? ?Toast.makeText(MainActivity.this, "注冊成功", Log.i("MainActivity", "檢測到你的注冊信息:" + "名字:" + name + " ?郵箱:" + id + " ?性別:" + sex+" ?愛好:"+hobby));
? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ?break;
? ? ? ? ?}
? ? ?}
?
? ? public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
? ? ? ? String motion =buttonView.getText().toString();
? ? ? ? if(isChecked){
? ? ? ? ? ? if(!hobby.contains(motion)){
? ? ? ? ? ? ? ? hobby = hobby + motion;
? ? ? ? ? ? }
? ? ? ? }else {
? ? ? ? ? ? if(hobby.contains(motion)){
?
? ? ? ? ? ? ? hobby=hobby.replace(motion,"");
? ? ? ? ? ? }
?
? ? ? ? }
}
?
}

我沒有輸入愛好,所以控制臺輸出null

這個代碼較簡單,xml用到的都是一些簡單的線性布局,和一些對控件位置和id的改動,定義,Java文件用的是對xml控件的獲取和輸出,展示!

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android利用HelloChart繪制曲線

    Android利用HelloChart繪制曲線

    這篇文章主要為大家詳細介紹了Android利用HelloChart繪制曲線,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • android連續(xù)拖動導致掛起的解決方法

    android連續(xù)拖動導致掛起的解決方法

    本文給大家分享的是在安卓的項目開發(fā)中遇到連續(xù)拖動對象,導致掛起的問題的解決方法,也是經(jīng)過很多網(wǎng)友的提示,最終才找到解決方法,這里記錄一下,分享給大家。
    2015-05-05
  • Android音樂播放器制作 加入控制臺(三)

    Android音樂播放器制作 加入控制臺(三)

    這篇文章主要為大家詳細介紹了Android音樂播放器的制作方法,如何加入控制臺,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-02-02
  • Android自定義彈框Dialog效果

    Android自定義彈框Dialog效果

    這篇文章主要為大家詳細介紹了Android自定義彈框Dialog效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Flutter集成到已有iOS工程的方法步驟

    Flutter集成到已有iOS工程的方法步驟

    這篇文章主要介紹了Flutter集成到已有iOS工程的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-03-03
  • Android實現(xiàn)固定屏幕顯示的方法

    Android實現(xiàn)固定屏幕顯示的方法

    這篇文章主要介紹了Android實現(xiàn)固定屏幕顯示的方法,實例分析了Android屏幕固定顯示所涉及的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-07-07
  • Android音頻開發(fā)之錄制音頻(WAV及MP3格式)

    Android音頻開發(fā)之錄制音頻(WAV及MP3格式)

    這篇文章主要為大家介紹了Android如何實現(xiàn)音頻文件的錄制(WAV及MP3格式),文中代碼具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-12-12
  • 一分鐘實現(xiàn)Android遮罩引導視圖

    一分鐘實現(xiàn)Android遮罩引導視圖

    本文通過一分鐘的時間教大家實現(xiàn)Android遮罩引導視圖,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-03-03
  • Android Flutter基于WebSocket實現(xiàn)即時通訊功能

    Android Flutter基于WebSocket實現(xiàn)即時通訊功能

    WebSocket是一種在單個TCP連接上進行全雙工通信的協(xié)議。本文將利用Flutter WebSocket實現(xiàn)即時通訊功能,文中示例代碼講解詳細,感興趣的可以了解一下
    2022-03-03
  • Android開發(fā)筆記之圖片緩存、手勢及OOM分析

    Android開發(fā)筆記之圖片緩存、手勢及OOM分析

    這篇文章主要介紹了Android開發(fā)筆記之圖片緩存、手勢及OOM分析 的相關(guān)資料,需要的朋友可以參考下
    2016-01-01

最新評論

金门县| 昭通市| 鹿邑县| 仙桃市| 孙吴县| 凤庆县| 巨鹿县| 横峰县| 曲水县| 黄平县| 多伦县| 泽州县| 福泉市| 兴国县| 新竹市| 阿尔山市| 岑溪市| 芒康县| 闽侯县| 繁峙县| 西盟| 宝坻区| 兴宁市| 长春市| 威信县| 西丰县| 崇明县| 固始县| 正阳县| 平陆县| 慈溪市| 庆阳市| 大兴区| 呼图壁县| 渝北区| 峨山| 永和县| 宿松县| 新郑市| 肇源县| 阜平县|