Android studio实现多个按钮跳转多个页面_木头科技㉿的博客-程序员秘密_android studio一个界面多个按钮跳转

技术标签: android studio  Android  

Android studio实现多个按钮跳转多个页面

Android studio通过多个按钮实现多个页面的跳转

要求下一个页面有音频、图片、单选按钮(RadioGroup)和复选框(CheckBox),还要求有文本输入框(EditText)和Bundle类及应用Intent传递数据。

其共有五个页面,一应俱全,望对其有帮助!

久违的更新,直接来干货,原项目已上传资源库,有问题私信V:mutou88848
在这里插入图片描述

一、实现效果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

二、布局配置文件

1、Text.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:background="@drawable/abc">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="67dp"
        android:gravity="center"
        android:text="Android实践示例"
        android:textColor="#FFD700"
        android:textSize="32sp" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="77dp"
        android:src="@drawable/bbb" />

    <Button
        android:id="@+id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="150dp"
        android:layout_marginTop="3dp"
        android:layout_marginBottom="8dp"
        android:text="个人音乐"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn2"
        android:layout_width="wrap_content"
        android:layout_height="47dp"
        android:layout_marginLeft="150dp"
        android:layout_marginTop="3dp"
        android:layout_marginBottom="8dp"
        android:text="个人相册"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn3"
        android:layout_width="wrap_content"
        android:layout_height="47dp"
        android:layout_marginLeft="150dp"
        android:layout_marginTop="3dp"
        android:layout_marginBottom="8dp"
        android:text="个人信息"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn4"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:layout_marginLeft="150dp"
        android:layout_marginTop="3dp"
        android:layout_marginBottom="8dp"
        android:text="用户登录"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:layout_width="133dp"
        android:layout_height="40dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="41dp"
        android:layout_marginRight="8dp"
        android:ems="10"
        android:gravity="center"
        android:text="字典查词"
        android:textColor="#FF5722"
        android:textSize="20sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />


    <EditText
        android:id="@+id/edit"
        android:layout_width="220dp"
        android:layout_height="60dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="41dp"
        android:layout_marginRight="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="请输入你要查询的词组"
        android:textSize="18sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/txt2" />

    <Button
        android:id="@+id/btn5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="查询"
        android:layout_margin="10dp"
        android:background="@drawable/tuh"
        android:textColor="#ffff"
        android:textSize="24sp" />

<!--    <ImageView-->
<!--        android:layout_width="match_parent"-->
<!--        android:layout_height="103dp"-->
<!--        android:src="@drawable/qqqq" />-->
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/qqqq"/>


</LinearLayout>
</ScrollView>

2、text1.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="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginTop="20dp"
    android:layout_marginLeft="80dp">

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/tt" />
    <TextView
        android:id="@+id/txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="播放音乐"
        android:textSize="24sp" />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageButton
            android:id="@+id/Start"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/music_play" />
        <ImageButton
            android:id="@+id/Stop"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/music_stop" />
        <Button
            android:id="@+id/btn11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="返回"
            android:textSize="24sp"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="40dp"
            android:layout_marginLeft="3dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"/>
    </LinearLayout>
</LinearLayout>

3、text2.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="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/abc"
    android:id="@+id/img">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="206dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:srcCompat="@drawable/aaaa"
        tools:ignore="MissingConstraints" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="277dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:srcCompat="@drawable/dddd"
        tools:ignore="MissingConstraints" />
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:srcCompat="@drawable/qqqq"
        tools:ignore="MissingConstraints" />
    <Button
        android:id="@+id/btn11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="返回"
        android:textSize="24sp"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="40dp"
        android:layout_marginLeft="3dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

</LinearLayout>

4、text3.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
    >
    <!--androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"/-->

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注册登记信息!"
            android:textSize="34sp"
            android:textStyle="bold"
            android:layout_gravity="center"
            android:textColor="#F44336"
            android:gravity="center"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="个人信息:"
            android:textColor="#FF9966"
            android:textSize="24sp"
            android:textStyle="bold" />


        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="1.姓名:"

            android:textColor="#254CC4"
            android:textSize="14sp" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:layout_marginTop="10dp"
            android:textSize="14sp"
            android:drawableLeft="@drawable/yonghu"
            android:hint="Name"
            android:drawablePadding="10dp"
            android:inputType="textPersonName"
            />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="32dp"
            android:layout_marginTop="10dp"
            android:text="2.学校:"
            android:textColor="#093A9C"
            android:textSize="14sp"
            />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:layout_marginTop="10dp"
            android:textSize="14sp"
            android:hint="School"
            android:drawablePadding="10dp"
            android:drawableLeft="@drawable/school"
            android:inputType="textPersonName"
            />
        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="32dp"
            android:layout_marginTop="10dp"
            android:text="3.电话:"
            android:textColor="#093A9C"
            android:textSize="14sp"
            />

        <EditText
            android:id="@+id/editText3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:layout_marginTop="10dp"
            android:textSize="14sp"
            android:hint="Tell"
            android:drawableLeft="@drawable/tel"
            android:drawablePadding="10dp"
            android:inputType="phone"
            />
        <RadioGroup
            android:layout_marginTop="10dp"
            android:id="@+id/rg_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <TextView
                android:id="@+id/textView6"
                android:layout_width="wrap_content"
                android:layout_height="32dp"
                android:layout_marginTop="10dp"
                android:text="4.性别:"
                android:textColor="#093A9C"
                android:textSize="14sp"
                />

            <RadioButton
                android:id="@+id/rb_1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="男生"
                android:layout_marginTop="10dp"
                android:textSize="14sp"
                android:checked="true"
                />
            <RadioButton
                android:id="@+id/rb_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="女生"
                android:textSize="14sp"
                android:layout_marginTop="10dp"
                />
        </RadioGroup>
        <TextView
            android:id="@+id/textView7"
            android:layout_width="wrap_content"
            android:layout_height="32dp"
            android:layout_marginTop="10dp"
            android:text="5.是否有以下情况:"
            android:textColor="#093A9C"
            android:textSize="14sp"
            />
        <CheckBox
            android:id="@+id/cb1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="是否是大学生?"
            android:textSize="14sp"
            android:checked="true"
            android:textColor="#9C27B0"
            />

        <CheckBox
            android:id="@+id/cb2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="是否是帅哥?"
            android:textSize="14sp"
            android:textColor="#9C27B0"
            android:layout_marginTop="10dp"
            android:checked="true"
            />
        <CheckBox
            android:id="@+id/cb3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="是否在宿舍学习?"
            android:textSize="14sp"
            android:textColor="#9C27B0"
            android:layout_marginTop="10dp"
            />
        <CheckBox
            android:id="@+id/cb4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="是否打游戏?"
            android:textSize="14sp"
            android:textColor="#9C27B0"
            android:layout_marginTop="10dp"
            />

        <!--Button
            android:id="@+id/button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="提交"
            android:textSize="20dp"
            android:textColor="#AF1237"/-->

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="返回!"
            android:layout_margin="10dp"
            android:background="@drawable/tuh"
            android:textColor="#ffff"
            android:textSize="24sp"

            />
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/www"/>
    </LinearLayout>

</ScrollView>

5、text4.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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ImageView
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:src="@drawable/login_man"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="48dp"/>
    <EditText
        android:id="@+id/login_id"
        android:layout_width="320dp"
        android:layout_height="48dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="48dp"
        android:background="@drawable/login_div_bg"
        android:paddingLeft="8dp"
        android:text="请输入账号" />
    <EditText
        android:id="@+id/login_password"
        android:layout_width="320dp"
        android:layout_height="48dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="16dp"
        android:background="@drawable/login_div_bg"
        android:paddingLeft="8dp"
        android:text="请输入密码" />
    <Button
        android:id="@+id/login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登录"
        android:textSize="20dp"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="155dp"/>
</LinearLayout>

6、text5.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">
    <!--    tools:context=".MainActivity">-->

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:text="欢迎来到字典查询"
        android:textSize="30sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.508"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.2" />

    <TextView
        android:id="@+id/txt2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:textSize="24sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintVertical_bias="0.3" />

    <Button
        android:id="@+id/btn6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="248dp"
        android:layout_marginLeft="8dp"
        android:text="返回到字典"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.478"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

三、逻辑控制代码

1、main.java

package com.example.test;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class main extends AppCompatActivity {
    
    Button btn1,btn2,btn3,btn4,btn5;
    EditText edit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);

        setContentView(R.layout.text);

        btn1 = (Button) findViewById(R.id.btn1);
        btn2 = (Button) findViewById(R.id.btn2);
        btn3 = (Button) findViewById(R.id.btn3);
        btn4 = (Button) findViewById(R.id.btn4);
        btn5 = (Button) findViewById(R.id.btn5);
        edit=(EditText)findViewById(R.id.edit);

        btn1.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
    
                Intent intent = new Intent(main.this, MainText1.class);
                startActivity(intent);
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
    
                Intent intent = new Intent(main.this, MainText2.class);
                startActivity(intent);
            }
        });
        btn3.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
    
                Intent intent = new Intent(main.this, MainText3.class);
                startActivity(intent);
            }
        });
        btn4.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
    
                Intent intent = new Intent(main.this, MainText4.class);
                startActivity(intent);
            }
        });
        btn5.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
    
                Intent intent = new Intent(main.this, MainText5.class);
                Bundle bundle = new Bundle();
                bundle.putString("edit", edit.getText().toString());
                intent.putExtras(bundle);
                startActivity(intent);
            }
        });

    }


}

2、maintext1.java

package com.example.test;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainText1 extends Activity {
    
    ImageButton Start,Stop;
    MediaPlayer mp;
    Button btn1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.text1);

        Start=(ImageButton)findViewById(R.id.Start);
        Stop=(ImageButton)findViewById(R.id.Stop);

        Start.setOnClickListener(new mStart());
        Stop.setOnClickListener(new mStop());

        try {
    
            mp= MediaPlayer.create(this, R.raw.abc);
            mp.setLooping(true);
        }
        catch(Exception e){
    
            Toast.makeText(this,"play error", Toast.LENGTH_LONG).show();
        }
    }
    class mStart implements View.OnClickListener{
    
        @Override
        public void onClick(View v) {
    
            try {
    
                if(!mp.isPlaying()){
    
                    mp.start();
                    Start.setImageResource(R.drawable.music_pause);
                }
                else {
    
                    mp.pause();
                    Start.setImageResource(R.drawable.music_play);
                }
            }
            catch(Exception e){
    e.printStackTrace();}
        }
    }
    class mStop implements View.OnClickListener{
    
        @Override
        public void onClick(View v) {
    
            mp.reset();
            try {
    
                mp = MediaPlayer.create(MainText1.this, R.raw.abc);
                mp.setLooping(true);
            }
            catch(Exception e){
     e.printStackTrace();}
            Start.setImageResource(R.drawable.music_play);
        }
    }

}

3、maintext2.java

package com.example.test;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;


import androidx.appcompat.app.AppCompatActivity;

import java.util.ResourceBundle;

public class MainText2 extends AppCompatActivity implements View.OnClickListener {
    
    Button btn11;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.text2);

    }

    @Override
    public void onClick(View v) {
    

    }
}

4.maintext3.java

package com.example.test;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class MainText3 extends AppCompatActivity implements View.OnClickListener {
    
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.text3);

    }

    @Override
    public void onClick(View v) {
    

    }
}

5、maintext4.java

package com.example.test;
import android.app.Activity;
import android.os.Bundle;
//import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainText4 extends AppCompatActivity implements View.OnClickListener
{
    
    Button btn;
    EditText login_id,login_password;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.text4);
        login_id = (EditText) findViewById(R.id.login_id);
        login_password = (EditText) findViewById(R.id.login_password);
        btn = (Button) findViewById(R.id.login_button);
        btn.setOnClickListener(this);
    }
    @Override
    public void onClick(View v)
    {
    
        String  str = login_id.getText()+" "+login_password.getText();
        Toast.makeText(this,str,Toast.LENGTH_LONG).show();
    }

}

6、maintext5.java

package com.example.test;
import android.content.Intent;
import android.os.Bundle;
//import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainText5 extends AppCompatActivity implements View. OnClickListener{
    
    Button btn6;
    TextView txt2;
    @Override
    public void onCreate(Bundle bunde) {
    
        super.onCreate(bunde);
        setContentView(R.layout.text5);
        txt2=(TextView)findViewById(R.id.txt2);
        btn6 = (Button)findViewById(R.id.btn6);
        Bundle bb = this.getIntent().getExtras();
        String str = bb.getString("edit");
        txt2.setText(str);
        btn6.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
    
        Intent intent2 = new Intent();
        intent2.setClass(this, main.class);
        startActivityForResult(intent2,0);//返回前一页面界面
    }
}

四、配置信息文件AndroidMAnifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Test">
        <activity android:name=".main">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MainText1"></activity>
        <activity android:name=".MainText2"></activity>
        <activity android:name=".MainText3"></activity>
        <activity android:name=".MainText4"></activity>
        <activity android:name=".MainText5"></activity>
    </application>

</manifest>

在这里插入图片描述

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/wkt1105436760/article/details/116810593

智能推荐

使用 vim + ctags + cscope + taglist 阅读源码_weixin_34138521的博客-程序员秘密

2019独角兽企业重金招聘Python工程师标准&gt;&gt;&gt; ...

Native for Mysql 连接阿里云数据库(内网连接和外网连接。)_wk2197727的博客-程序员秘密

Native for Mysql  连接阿里云服务器。看看阿里云服务器是公网IP还是内网IP(使用SecureCRT远程到跳板服务器上,也称堡垒机。)1.阿里云是内网IP:如果是内网IP,可以通过外网IP进行转发;     这样一个场景:A是办公网络的一台windows主机,B是一台linux堡垒机,C是生产环境一台oracle主机,A只

正则表达式的概念_weixin_30820151的博客-程序员秘密

正则表达式{ 正则表达式的意思:我们程序员写一个正则表达式,在一段字符串中找到跟我们表达式表示的一样的内容{ 例如1: 表达式:ABC ,字符串1: ABCDEFG , 字符串2: ABDCEFG ,字符串3: ABDABCEFG ,字符串4: ABCABC 结论: 字符串1 匹配成立, 结果 ABC 字符串2 匹配失败, 结果 空...

Java集合框架分析(五)LinkedHashMap分析_initialcapacity – the initial capacity linkedhashm_普通网友的博客-程序员秘密

LinkedHashMap简介public class LinkedHashMap&lt;K,V&gt; extends HashMap&lt;K,V&gt; implements Map&lt;K,V&gt;复制代码继承自 HashMap,一个有序的 Map 接口实现,这里的有序指的是元素可以按插入顺序或访问顺序排列;与 HashMap 相比,因为 LinkedHashMap 是继承自 Ha...

Appium H5自动化测试_测试小白-千寻的博客-程序员秘密

目录问题思考解决思路contextWebViewH5元素定位环境搭建操作步骤Webview 调试模式检查与开启方式         H5定位实践案例问题思考在混合开发的App中,经常会有内嵌的H5页面。那么这些H5页面元素该如何进行定位操作呢?解决思路针对这种场景直接使用基于Andriod原生控件进行元素定位是行不通的,Web网页是单独的B/S架构,...

catkin_make 编译包无效(没反应)_catkin_make无法编译_南苏月的博客-程序员秘密

- catkin_make 编译指定的功能包失效?可能是如下原因:这时需要编译全部功能包,catkin_make -DCATKIN_WHITELIST_PACKAGES=""或者在双引号内加入你需要编译的包catkin_make -DCATKIN_WHITELIST_PACKAGES="package_name1;package_name2"注意不是src下的文件夹名字,而是文件夹下package.xml里面的包的名字,或者CMaklists.txt的项目的名字。不然会找不到,导致不会编译。

随便推点

【Python爬虫】AttributeError: ‘WebDriver‘ object has no attribute ‘switch_to_window‘_笔触狂放的博客-程序员秘密

在使用Selenium 库对动态网站进行爬取操作的时候,出现 switch_to_window属性不存在的错误,出现这个错误说明该属性在库中已经不存在了,可能该属性是低版本中出现过,现在这个属性的用法要换成。...

initramfs的加载过程(从uboot到kernel)_yiyeguzhou100的博客-程序员秘密

initramfs是一个cpio格式的包,压缩方式可以选择xz,但initramfs并不按照任何文件系统的格式组织数据。initramfs可以理解为initramfs=特定的文件夹(文件),把这些文件夹按照cpio格式打包再压缩就是initramfs(如生成最终文件initramfs.cpio.xz)。系统使用 initramfs 作为它的根文件系统(或临时根文件系统)甚至不需要将文件系统驱动

python gdal教程_GDAL python教程(1)——用OGR读写矢量数据_weixin_40007541的博客-程序员秘密

本教程的讲义和源码都是取自Utah State University的openGIS课程本人只是做点翻译,写写学习体会而已,版权属于原作者。欢迎转载,不过别忘了上面这段话。==================================================为什么用open source?优点免费,适合个人和小公司强大的开发工具,找bug更容易跨平台,windows和linux都能用...

C++程序:求多个同学的平均成绩然后求低于它的,打印出来(不知道同学的个数的)_tnarpfkd6的博客-程序员秘密

VC++下的求多个同学的平均成绩然后求低于它的,打印出来(不知道同学的个数的) #include int main(){    int num, i;    //变量定义    float *score, aver, sum = 0;        printf("Input the number of the scores:");  //输入同学个数    scanf("%d", &nu

ubuntu18.04安装sougou输入法_ubuntu18。04 sougou xiezai_ustczhng2012的博客-程序员秘密

卸载IBUS sudo apt-get purge ibus 安装fcitx sudo apt install fcitx fcitx-googlepinyin fcitx-table-wbpy fcitx-pinyin fcitx-sunpinyin 后面步骤参考https://pinyin.sogou.com/linux/help.php

2019微生物组—宏基因组分析专题研讨会_prokka cd-hit_刘永鑫Adam的博客-程序员秘密

文章目录课程简介课程大纲一、分析平台搭建二、生信基础三、图表解读和绘制专题四、宏基因组学概述五、宏基因组学有参分析流程六、宏基因组无参分析流程七、高级分析与可视化实战学习完本课程,你能得到什么?主讲教师往期课程瞬间助教团队授课模式培训时间授课地点课程价格课程福利在广大粉丝的期待下,《生信宝典》联合《宏基因组》在2019年3月22-24日,北京鼓楼推出《宏基因组分析》专题培训第三期,为大家提供一...

推荐文章

热门文章

相关标签