欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

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

xml界面設(shè)計(前面已發(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)文章

  • kotlin開發(fā)cli工具小技巧詳解

    kotlin開發(fā)cli工具小技巧詳解

    這篇文章主要為大家介紹了kotlin開發(fā)cli工具小技巧詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-12-12
  • 三種Android單擊事件onclick的實現(xiàn)方法

    三種Android單擊事件onclick的實現(xiàn)方法

    這篇文章主要為大家詳細介紹了三種Android單擊事件onclick的實現(xiàn)方法,感興趣的小伙伴們可以參考一下
    2016-05-05
  • appium運行各種坑爹報錯問題及解決方法【推薦】

    appium運行各種坑爹報錯問題及解決方法【推薦】

    這篇文章主要介紹了 appium運行各種坑爹報錯問題及解決方法,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-06-06
  • Android基于google Zxing實現(xiàn)各類二維碼掃描效果

    Android基于google Zxing實現(xiàn)各類二維碼掃描效果

    這篇文章主要介紹了Android基于google Zxing實現(xiàn)各類二維碼掃描效果的相關(guān)資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-02-02
  • Android中PopuWindow實現(xiàn)下拉列表實例

    Android中PopuWindow實現(xiàn)下拉列表實例

    本篇文章主要介紹了Android中PopuWindow實現(xiàn)下拉列表實例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-07-07
  • Android開發(fā)手機無線調(diào)試的方法

    Android開發(fā)手機無線調(diào)試的方法

    今天小編就為大家分享一篇關(guān)于Android開發(fā)手機無線調(diào)試的方法,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-12-12
  • Android實現(xiàn)簡易的計算器

    Android實現(xiàn)簡易的計算器

    這篇文章主要為大家詳細介紹了Android實現(xiàn)簡易的計算器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-10-10
  • Android中SwipeBack實現(xiàn)右滑返回效果

    Android中SwipeBack實現(xiàn)右滑返回效果

    這篇文章主要介紹了Android中SwipeBack實現(xiàn)右滑返回效果的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • Android開發(fā)使用PopupMenu創(chuàng)建彈出式菜單完整實例

    Android開發(fā)使用PopupMenu創(chuàng)建彈出式菜單完整實例

    這篇文章主要介紹了Android開發(fā)使用PopupMenu創(chuàng)建彈出式菜單,結(jié)合完整實例形式分析了Android基于PopupMenu對象創(chuàng)建的彈出式菜單相關(guān)操作技巧與注意事項,需要的朋友可以參考下
    2019-03-03
  • Android快速分析apk工具aapt的使用教程

    Android快速分析apk工具aapt的使用教程

    這篇文章主要介紹了Android快速分析apk工具aapt的使用教程,本文講解了什么是aapt、主要用法、使用aapt、查看apk的基本信息、查看基本信息、查看應(yīng)用權(quán)限等內(nèi)容,需要的朋友可以參考下
    2015-04-04

最新評論