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

Android studio按鈕點(diǎn)擊頁面跳轉(zhuǎn)詳細(xì)步驟

 更新時(shí)間:2023年06月13日 15:04:45   作者:Swallow_L02  
在Android應(yīng)用程序中,頁面跳轉(zhuǎn)是非常常見的操作,下面這篇文章主要給大家介紹了關(guān)于Android studio按鈕點(diǎn)擊頁面跳轉(zhuǎn)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下

(1)先創(chuàng)建一個(gè)要跳轉(zhuǎn)的頁面,即一個(gè)新的頁面,該頁面是點(diǎn)擊之后跳轉(zhuǎn)的。

步驟:app--->src-->main-->res-->layout(右擊)-->New-->Activity-->Empty Activity

 創(chuàng)建好以后,此時(shí)會(huì)生成一個(gè)同名的java文件。

初始時(shí)的界面代碼如下,界面展示在后面,僅供參考。

<?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"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    tools:context=".MainActivity">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用戶名:"/>
        <EditText
            android:id="@+id/edit1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="____________"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密碼:"/>
        <EditText
            android:id="@+id/edit2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="____________"
            android:password="true"/>
    </LinearLayout>
    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登錄"/>
</LinearLayout>

跳轉(zhuǎn)的界面代碼,同樣界面展示在后面。

<?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"
    android:gravity="center"
    android:background="@drawable/bg">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40dp"
        android:textColor="#DDE0E4"
        android:text="歡迎進(jìn)入智慧農(nóng)業(yè)系統(tǒng)"
        />
</LinearLayout>

由于頁面跳轉(zhuǎn)沒有變換,變化的是主界面,在主界面點(diǎn)擊按鈕,使頁面發(fā)生變化,因此只需要編寫

MainActivity.java文件。

注:不同的文件名,包名不同,以下為我個(gè)人的編寫代碼,僅供參考。

package com.example.signin;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
 
public class MainActivity extends AppCompatActivity {
 
    private Button btn;
    private EditText edit1;
    private EditText edit2;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        initView();
    }
 
    private void initView() {
        btn = (Button) findViewById(R.id.btn);
        edit1 = (EditText) findViewById(R.id.edit1);
        edit2 = (EditText) findViewById(R.id.edit2);
 
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(edit1.getText().toString().equals("aaa") &&
                   edit2.getText().toString().equals("aaa")){
                    Intent intent = new Intent(MainActivity.this,nextActive.class);
                    startActivity(intent);
                }
                else {
                    Toast.makeText(MainActivity.this,"輸入有誤,請重新輸 
                     入",Toast.LENGTH_LONG).show();
                }
            }
        });
    }
 
}

以下是我完成的登錄跳轉(zhuǎn)頁面,僅供參考。

初始時(shí)的界面:

輸入正確的用戶名和密碼以后,跳轉(zhuǎn)到如下界面,僅供參考。

 如果沒有輸入正確,將有文字提示:

總結(jié)

到此這篇關(guān)于Android studio按鈕點(diǎn)擊頁面跳轉(zhuǎn)的文章就介紹到這了,更多相關(guān)Android studio點(diǎn)擊頁面跳轉(zhuǎn)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java內(nèi)存模型及其作用詳解

    Java內(nèi)存模型及其作用詳解

    在現(xiàn)代計(jì)算機(jī)系統(tǒng)中,尤其是多處理器架構(gòu)下,每個(gè)處理器都有自己的高速緩存,而主內(nèi)存(RAM)是所有處理器共享的數(shù)據(jù)存儲(chǔ)區(qū)域,這篇文章主要介紹了深入理解Java內(nèi)存模型及其作用,需要的朋友可以參考下
    2024-04-04
  • java導(dǎo)出包含多個(gè)sheet的Excel代碼示例

    java導(dǎo)出包含多個(gè)sheet的Excel代碼示例

    這篇文章主要介紹了java導(dǎo)出包含多個(gè)sheet的Excel,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • spring是如何實(shí)現(xiàn)聲明式事務(wù)的

    spring是如何實(shí)現(xiàn)聲明式事務(wù)的

    這篇文章主要介紹了spring是如何實(shí)現(xiàn)聲明式事務(wù)的,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • Java中String使用方法及分析(UTF-8簡單編碼/解碼器實(shí)現(xiàn))

    Java中String使用方法及分析(UTF-8簡單編碼/解碼器實(shí)現(xiàn))

    在Java中String類是用來表示和操作字符串的,它是Java中最常用的類之一,提供了豐富的方法來創(chuàng)建、操作和查詢字符串,這篇文章主要介紹了Java中String使用方法及分析(UTF-8簡單編碼/解碼器實(shí)現(xiàn))的相關(guān)資料,需要的朋友可以參考下
    2025-12-12
  • SpringBoot使用Redisson實(shí)現(xiàn)分布式鎖(秒殺系統(tǒng))

    SpringBoot使用Redisson實(shí)現(xiàn)分布式鎖(秒殺系統(tǒng))

    這篇文章主要為大家詳細(xì)介紹了SpringBoot使用Redisson實(shí)現(xiàn)分布式鎖,秒殺系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • 一個(gè)依賴搞定?Spring?Boot?接口防盜刷的流程分析

    一個(gè)依賴搞定?Spring?Boot?接口防盜刷的流程分析

    kk-anti-reptile 是適用于基于 spring-boot 開發(fā)的分布式系統(tǒng)的反爬蟲組件,這篇文章主要介紹了一個(gè)依賴搞定?Spring?Boot?接口防盜刷,需要的朋友可以參考下
    2022-06-06
  • Spring?Data?JPA系列QueryByExampleExecutor使用詳解

    Spring?Data?JPA系列QueryByExampleExecutor使用詳解

    這篇文章主要為大家介紹了Spring?Data?JPA系列QueryByExampleExecutor使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • Java 十進(jìn)制轉(zhuǎn)二、八、十六進(jìn)制的字符串

    Java 十進(jìn)制轉(zhuǎn)二、八、十六進(jìn)制的字符串

    本文主要介紹了十進(jìn)制轉(zhuǎn)二進(jìn)制;十進(jìn)制轉(zhuǎn)八進(jìn)制;十進(jìn)制轉(zhuǎn)十六進(jìn)制的方法,具有很好的參考價(jià)值,下面跟著小編一起來看下吧
    2017-02-02
  • Android實(shí)現(xiàn)兼容的水波紋效果

    Android實(shí)現(xiàn)兼容的水波紋效果

    Android的水波紋效果只有高版本才有,我們希望自己的應(yīng)用在低版本用低版本的陰影,而高版本用水波紋,這怎么做呢?下面一起來學(xué)習(xí)學(xué)習(xí)。
    2016-08-08
  • Spring(二):Spring通過IOC來創(chuàng)建對象

    Spring(二):Spring通過IOC來創(chuàng)建對象

    下面小編就為大家?guī)硪黄斦凷pring對IOC的理解(推薦篇)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2021-07-07

最新評論

成都市| 太原市| 库尔勒市| 江门市| 探索| 天峨县| 特克斯县| 邳州市| 株洲市| 易门县| 兴安盟| 新竹市| 阜城县| 乐昌市| 沧源| 衡阳市| 墨竹工卡县| 雅安市| 浦北县| 中卫市| 乌鲁木齐市| 阳城县| 哈巴河县| 石棉县| 多伦县| 大方县| 安阳市| 赤城县| 三台县| 德清县| 偏关县| 九寨沟县| 巴林右旗| 灵山县| 临潭县| 西平县| 民乐县| 闽侯县| 涿鹿县| 吉林市| 南雄市|