Android 跳轉過後關閉本介面
activity_main.xml
<?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"> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="我靠" android:gravity="center" android:textSize="200dp"/> </LinearLayout>
MainActivity
package com.example.a12236.myapplication; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView textView = findViewById(R.id.tv); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //跳轉 startActivity(new Intent(MainActivity.this,Main2Activity.class)); //跳轉完以後關閉本介面 finish(); } }); } }
activity_main2.xml
<?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=".Main2Activity"> <TextView android:id="@+id/hl" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="嗨嘍" android:gravity="center" android:textSize="200dp"/> </LinearLayout>
Main2Activity
package com.example.a12236.myapplication; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class Main2Activity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); TextView textView = findViewById(R.id.hl); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //跳轉 startActivity(new Intent(Main2Activity.this,MainActivity.class)); //跳轉完以後關閉本介面 finish(); } }); } }
無聊弄一下,各位大佬別噴.......!
相關文章
- C# 介面跳轉-登陸之後跳轉至主視窗C#
- Android開發實現連續跳轉幾個介面後在最後一個介面完美跳回最初的介面Android
- Android 書本開啟和關閉動畫Android動畫
- C# winForm 視窗跳轉後關閉上一個視窗的方法C#ORM
- 【ionic】介面跳轉
- MFC登入介面,跳轉到功能介面
- android webview 跳轉AndroidWebView
- Android路由框架AnnoRouter:使用Java介面來定義路由跳轉Android路由框架Java
- Android之Activity介面跳轉--生命週期方法呼叫順序Android
- 在session過期後如何跳轉到登入頁面Session
- 怎麼關閉win10鎖屏介面 windows關閉鎖屏介面的方法Win10Windows
- mysql關閉過程MySql
- Activity過渡(跳轉)動畫動畫
- Flutter中如何進行介面跳轉Flutter
- 《匿名》第六課----基本介面跳轉
- Win10系統開機後跳過鎖屏介面怎麼設定Win10
- ADFS3.0/4.0 訪問登入頁跳轉到登出介面後再跳轉回登入頁的方法S3
- Android 透過scheme跳轉支付寶實現支付AndroidScheme
- Android activity相互跳轉後臺出現兩個頁面的坑Android
- 求救:jdbc與mysql透過Servlet操作後連線關閉不了JDBCMySqlServlet
- layer關閉重新整理父介面
- 分享一個session過期後根據guard跳轉的實現Session
- ios萬能跳轉介面方法(Runtime)iOS
- Android右滑關閉Activity介面功能-自定義控制元件實現Android控制元件
- 防止關閉windows (轉)Windows
- 如何優雅的實現介面跳轉 之 統跳協議協議
- Android 修改字型,跳不過的 TypefaceAndroid
- Linux 啟動過程, 初始化和關閉(轉)Linux
- Hybird推送通知然後跳轉appAPP
- Android 點選按鈕跳轉Android
- 織夢後臺登入成功又跳轉回登入介面與驗證碼
- ORACLE關閉過程淺析Oracle
- 登入成功跳轉回原來的介面
- App跳轉到許可權設定介面APP
- 視窗介面設計規範:介面關閉方式及介面疊加
- 快速關閉系統(轉)
- Ios、Android微信瀏覽器後退跳轉實現,及遇到的bugiOSAndroid瀏覽器
- Android解除安裝程式之後跳轉到指定的反饋頁面Android