国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Android開發(fā)——實(shí)現(xiàn)簡易登錄功能

這篇具有很好參考價(jià)值的文章主要介紹了Android開發(fā)——實(shí)現(xiàn)簡易登錄功能。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

登錄界面(mainActivity.xml)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"  
    android:layout_height="match_parent"
    android:id="@+id/wjh"  設(shè)置id,給mainActivity.java文件調(diào)用。
    android:background="@drawable/picture"
    android:orientation="vertical">


    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="143dp"
        android:text="@string/login"
        android:textSize="100sp"
        android:textColor="@color/black"
        android:gravity="center">
    </TextView>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="570dp"
        android:orientation="vertical"> 設(shè)置布局豎直排列

        <Space
            android:layout_width="match_parent"
            android:layout_height="100dp" />
        <EditText
            android:id="@+id/editTextText2" 
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="text"
            android:hint="@string/username"
            android:textColor="@color/black"
            android:textStyle="bold"
            android:layout_gravity="center"
            android:gravity="center"
            />

        <Space
            android:layout_width="match_parent"
            android:layout_height="100dp" />

        <EditText
            android:id="@+id/editTextTextPassword6"
            android:layout_width="300sp"
            android:layout_height="wrap_content"
            android:ems="10"
            android:textStyle="bold"
            android:inputType="textPassword"
            android:hint="@string/password"
            android:gravity="center"
            android:layout_gravity="center"
            android:textSize="20sp"
            />

        <Space
            android:layout_width="match_parent"
            android:layout_height="100dp" />

        <Button
            android:id="@+id/button"
            android:layout_width="150dp"
            android:layout_height="83dp"
            android:layout_gravity="center"
            android:text="@string/button"
            android:onClick="Jump"
            android:textColor="@color/cardview_light_background"
            android:background="@drawable/p2"
            />

    </LinearLayout>


</LinearLayout>

效果圖

?Android開發(fā)——實(shí)現(xiàn)簡易登錄功能,安卓開發(fā),android文章來源地址http://www.zghlxwxcb.cn/news/detail-856651.html

跳轉(zhuǎn)界面(activity_main2.xml)

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/success"
        android:textColor="@color/black"
        android:textStyle="bold"
        android:textSize="60sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:text="@string/success"
        android:textColor="@color/black"
        android:textSize="40sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toTopOf="@+id/textView1"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0" />

    <Space
        android:layout_width="wrap_content"
        android:layout_height="200dp"
        app:layout_constraintBottom_toTopOf="@+id/textView"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout_editor_absoluteX="199dp" />


</androidx.constraintlayout.widget.ConstraintLayout>

如何將兩個(gè)activity結(jié)合?

編輯mainActivity2.java文件

package com.example.myapplication;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;


onCreate() 方法是 Android 活動(dòng)(Activity)的生命周期方法之一,它在活動(dòng)被創(chuàng)建時(shí)調(diào)用。其主要作用是初始化活動(dòng)的用戶界面,設(shè)置布局內(nèi)容和相關(guān)資源,并執(zhí)行一些必要的初始化操作。
在 onCreate() 方法中,通常會(huì)執(zhí)行以下操作:
1.設(shè)置布局:調(diào)用 setContentView() 方法設(shè)置活動(dòng)的布局文件,即指定要在屏幕上顯示的用戶界面。
2.獲取 Intent 數(shù)據(jù):如果該活動(dòng)需要從其他活動(dòng)接收數(shù)據(jù),通常會(huì)通過 getIntent() 方法獲取傳遞過來的 Intent 對(duì)象,并從中提取所需的數(shù)據(jù)。
3.初始化界面元素:通過調(diào)用 findViewById() 方法初始化界面中的各種 UI 元素,例如按鈕、文本框、圖像視圖等。
4.設(shè)置事件監(jiān)聽器:為界面元素設(shè)置事件監(jiān)聽器,以便在用戶與之交互時(shí)執(zhí)行相應(yīng)的操作。
5.執(zhí)行其他初始化操作:執(zhí)行其他必要的初始化操作,例如數(shù)據(jù)加載、網(wǎng)絡(luò)請(qǐng)求、權(quán)限檢查等


public class mainActivity2 extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2); 
        引入mainActivity2.xml,使得兩個(gè)文件相互關(guān)聯(lián)。

        Intent intent = getIntent();
        intent用來存放數(shù)據(jù),進(jìn)行對(duì)數(shù)據(jù)的操作,
        在 Android 中,Intent 是用于在不同組件之間傳遞數(shù)據(jù)的對(duì)象
        
        String userInput = intent.getStringExtra("userInput");
        取到與自己通信的activity傳遞來的數(shù)據(jù),intent內(nèi)部存儲(chǔ)數(shù)據(jù)
        采用的是key-value結(jié)構(gòu)。此時(shí)的key是userInput

        TextView textView = findViewById(R.id.textView);
        與自己的activity.xml的文本框綁定
        
        textView.setText(userInput);
        將文本設(shè)置進(jìn)文本框
    }
}

AndroidManifest.xml中注冊(cè)新加的activity

</activity>
        <activity android:name=".mainActivity2"/>

activity_main.xml?

<Button
            android:id="@+id/button"
            android:layout_width="150dp"
            android:layout_height="83dp"
            android:layout_gravity="center"
            android:text="@string/button"
            android:onClick="Jump" 注冊(cè)Jump方法,在java文件中定義實(shí)現(xiàn)
            android:textColor="@color/cardview_light_background"
            android:background="@drawable/p2"
            />

mainActivity.java (實(shí)現(xiàn)點(diǎn)擊按鈕的方法)

    public void Jump(View view){
     
        EditText editText = findViewById(R.id.editTextText2);
        
        String userInput = editText.getText().toString();
        取到main_activity.xml中的輸入的用戶名一欄的數(shù)據(jù)

        Intent intent = new Intent(this, mainActivity2.class);
        創(chuàng)建intent對(duì)象進(jìn)行數(shù)據(jù)交互
        
        intent.putExtra("userInput", userInput);
        發(fā)送數(shù)據(jù),設(shè)置key值為userInput,value為取到的數(shù)據(jù)
        
        startActivity(intent);
        執(zhí)行
    }

到了這里,關(guān)于Android開發(fā)——實(shí)現(xiàn)簡易登錄功能的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Android前端+Spring Boot后端 登錄功能實(shí)現(xiàn)

    Android前端+Spring Boot后端 登錄功能實(shí)現(xiàn)

    創(chuàng)建項(xiàng)目后,自己添加包,框架如下 ? userController里的一些內(nèi)容,只供參考,代碼不全,無法實(shí)現(xiàn) 數(shù)據(jù)庫是直接在社區(qū)版IDEA里連接Mysql,在控制臺(tái)端創(chuàng)建的數(shù)據(jù)庫和user表,用于數(shù)據(jù)交互。 Activity包里是Activity Java類,主要響應(yīng)layout包里activity_login.xml等頁面布局內(nèi)的按鈕響應(yīng) a

    2024年02月12日
    瀏覽(23)
  • Android Studio|使用SqLite實(shí)現(xiàn)一個(gè)簡單的登錄注冊(cè)功能

    Android Studio|使用SqLite實(shí)現(xiàn)一個(gè)簡單的登錄注冊(cè)功能

    本學(xué)期學(xué)習(xí)了Android Studio這門課程,本次使用Android Studio自帶的sqlite數(shù)據(jù)庫實(shí)現(xiàn)一個(gè)簡單的登錄注冊(cè)功能。 目錄 一、了解什么是Android Studio? 二、了解什么是sqlite? 三、創(chuàng)建項(xiàng)目文件 ?四、創(chuàng)建活動(dòng)文件和布局文件。 五、創(chuàng)建數(shù)據(jù)庫,連接數(shù)據(jù)庫 ?六、創(chuàng)建實(shí)體類,實(shí)現(xiàn)注

    2024年02月06日
    瀏覽(49)
  • Android Studio實(shí)現(xiàn)Mysql(5.7)數(shù)據(jù)庫增刪改查(上)——用戶登錄功能實(shí)現(xiàn)

    Android Studio實(shí)現(xiàn)Mysql(5.7)數(shù)據(jù)庫增刪改查(上)——用戶登錄功能實(shí)現(xiàn)

    前言:如果android studio安裝和第一次跑helloworld有什么問題可以參考:(34條消息) Android Studio踩的那些坑(gradle build、unable to find tasks to···等等)_TidesWise的博客-CSDN博客 目錄 準(zhǔn)備工作 查詢學(xué)生數(shù)目demo:? 增刪改查完整案例 1、在Android Studio中新建項(xiàng)目My Application; 2、在Androi

    2024年02月10日
    瀏覽(19)
  • 手把手教你實(shí)現(xiàn):Android注冊(cè)登錄功能,通過本地服務(wù)器保存用戶賬號(hào)密碼到數(shù)據(jù)庫

    手把手教你實(shí)現(xiàn):Android注冊(cè)登錄功能,通過本地服務(wù)器保存用戶賬號(hào)密碼到數(shù)據(jù)庫

    代碼我放到文章最后面了 首先你需要電腦一臺(tái):如果沒有電腦將會(huì)很難辦呢 -----沃茲基碩德 下載并安裝以下開發(fā)工具 Android Studio 官網(wǎng)最新版 用來開發(fā) 安卓App IntelliJ IDEA 官網(wǎng)最新版 用來開發(fā) 后端 ,處理安卓APP的請(qǐng)求 Navicat for MySql 官網(wǎng)最新版 數(shù)據(jù)庫可視化工具,用來查看數(shù)

    2024年01月16日
    瀏覽(30)
  • Android開發(fā)之實(shí)現(xiàn)簡單的用戶登錄及登陸界面的UI設(shè)計(jì)(五)

    登陸界面的UI設(shè)計(jì) 編寫Java代碼,進(jìn)行簡單的用戶賬號(hào)和密碼判斷

    2024年02月11日
    瀏覽(88)
  • Android開發(fā)----實(shí)現(xiàn)登錄注冊(cè)頁面(創(chuàng)建本地?cái)?shù)據(jù)庫,對(duì)注冊(cè)的賬戶密碼進(jìn)行存儲(chǔ))

    Android開發(fā)----實(shí)現(xiàn)登錄注冊(cè)頁面(創(chuàng)建本地?cái)?shù)據(jù)庫,對(duì)注冊(cè)的賬戶密碼進(jìn)行存儲(chǔ))

    寫在前面: 本文實(shí)現(xiàn)了登錄注冊(cè)頁面的開發(fā),創(chuàng)建了本地?cái)?shù)據(jù)庫,存儲(chǔ)注冊(cè)的賬戶密碼。注冊(cè)賬戶為手機(jī)號(hào),對(duì)賬戶為手機(jī)號(hào)進(jìn)行了正則化驗(yàn)證。登錄成功跳轉(zhuǎn)至主頁面。 20221028-實(shí)現(xiàn)登錄注冊(cè)功能 首先說一下,項(xiàng)目部署是在原有項(xiàng)目新建兩個(gè)activity( 項(xiàng)目右鍵–new–activi

    2024年02月03日
    瀏覽(28)
  • android AccessibilityService無障礙功能開發(fā),實(shí)現(xiàn)自動(dòng)化測試

    android AccessibilityService無障礙功能開發(fā),實(shí)現(xiàn)自動(dòng)化測試,這里使用抖音為例子,僅供技術(shù)研究學(xué)習(xí)使用。 使用方法 安裝好APP后,需要打開無障礙功能,打開后,在次打開抖音APP,隨便找一個(gè)直播間,上下滑動(dòng)切換直接后,實(shí)現(xiàn)模擬點(diǎn)擊屏幕,可以自動(dòng)完成關(guān)注。 代碼如下

    2024年02月12日
    瀏覽(21)
  • android開發(fā)使用OkHttp自帶的WebSocket實(shí)現(xiàn)IM功能

    android開發(fā)使用OkHttp自帶的WebSocket實(shí)現(xiàn)IM功能

    目錄 一、背景 二、在項(xiàng)目中添加依賴包 三、框架調(diào)用 1、配置OkHttpClient ?2、調(diào)用Url,構(gòu)建WebSocket請(qǐng)求 3、建立連接 4、使用WebSocket對(duì)象發(fā)送消息 ? ? android app開發(fā)經(jīng)常會(huì)有IM需求,很多新手不曉得如何入手,難點(diǎn)在于通訊不中斷。其實(shí)android發(fā)展到今天,很多技術(shù)都很完善,有

    2024年02月08日
    瀏覽(25)
  • Android:實(shí)現(xiàn)安卓小程序-記事本(備忘錄)的開發(fā),教你如何增加拿到BAT大廠offer幾率

    Android:實(shí)現(xiàn)安卓小程序-記事本(備忘錄)的開發(fā),教你如何增加拿到BAT大廠offer幾率

    public MyBaseAdapter(Context context, List data) { this.context = context; this.data = data; } @Override public Object getItem(int i) { return null; } @Override public long getItemId(int i) { return 0; } @Override public int getCount() { if(data==null) return 0; return data.size(); } } 接著在編寫NoteAdapter類繼承上類,初始化view, 將Note條目的

    2024年04月25日
    瀏覽(91)
  • JavaWeb實(shí)現(xiàn)簡易的注冊(cè)登錄功能(與數(shù)據(jù)庫連接)

    JavaWeb實(shí)現(xiàn)簡易的注冊(cè)登錄功能(與數(shù)據(jù)庫連接)

    一、創(chuàng)建數(shù)據(jù)庫表連接 這里我們創(chuàng)建一個(gè)數(shù)據(jù)庫名為db_user,創(chuàng)建庫的使用可視化工具很簡單就不細(xì)說了,下面sql代碼塊是我們創(chuàng)建一個(gè)簡易用戶表為了方便我們后續(xù)進(jìn)行登錄注冊(cè)操作。 下面就是建好的表: 1、建一個(gè)與數(shù)據(jù)庫連接的file文件:db.properties 二、創(chuàng)建前端頁面 1、

    2024年01月19日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包