【android编程】第七讲-android Activity实践题

【android编程】第七讲-android Activity实践题

课堂笔记链接:https://blog.csdn.net/xbean1028/article/details/104904005

文章目录

  • 【android编程】第七讲-android Activity实践题
    • 1.Activity跳转练习
      • 1.0 题目要求
      • 1.1效果展示
      • 1.2 activity_main.xml
      • 1.3 activity_main2.xml
      • 1.4 MainActivity.java
      • 1.5 Main2Activity.java
    • 2. Activity 传递数据返回数据练习
      • 2.0 题目要求
      • 2.1 效果展示
      • 2.2 activity_main.xml
      • 2.3 activity_main2.xml
      • 2.4 MainActivity.java
      • 2.5 Main2Activity.java
      • 2.7 总结
    • 3. Activity综合练习
      • 3.0 题目要求
      • 3.1 效果展示
      • 3.2 activity_main.xml
      • 3.4 activity_introduce.xml
      • 3.5 activity_score.xml
      • 3.6 MainActivity.java
      • 3.7 IntroduceActivity.java
      • 3.7 ScoreActivity.java

1.Activity跳转练习

1.0 题目要求

  • 程序启动后显示主界面,

  • 按下进入子界面的按钮则程序进入子界面,

  • 按下子界面的返回按钮之后程序会重新返回主界面.

  • 按主界面的退出按钮后,程序退出。

1.1效果展示

【android编程】第七讲-android Activity实践题_第1张图片
【android编程】第七讲-android Activity实践题_第2张图片

1.2 activity_main.xml


<android.support.constraint.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="com.example.bean.myapplication316v0.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="主控界面"
        android:textSize="40dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.145"
        android:id="@+id/textView" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="进入子界面"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.401"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="退出程序"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.671"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent" />


android.support.constraint.ConstraintLayout>

1.3 activity_main2.xml


<android.support.constraint.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="com.example.bean.myapplication316v0.Main2Activity">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="子界面"
        android:textSize="40dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.183"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="返回主界面"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintVertical_bias="0.421" />
android.support.constraint.ConstraintLayout>

1.4 MainActivity.java

package com.example.bean.myapplication316v0;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button1 = (Button)findViewById(R.id.button1);
        Button button2 = (Button)findViewById(R.id.button2);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, Main2Activity.class);
                startActivity(intent);
            }
        });
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}

1.5 Main2Activity.java

package com.example.bean.myapplication316v0;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Main2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Button button3 = (Button)findViewById(R.id.button3);
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}

2. Activity 传递数据返回数据练习

2.0 题目要求

  • 主程序启动后,姓名栏中输入姓名如:“张三”,单击“进入子页面”按钮后,在子页面的上部显示在主程序中输入的姓名。
  • 单击“返回” 按钮。返回主程序。
  • 将子程序中编辑框的内容返回给主程序,并在主程序下方的文本框中显示。

2.1 效果展示

【android编程】第七讲-android Activity实践题_第3张图片
【android编程】第七讲-android Activity实践题_第4张图片

2.2 activity_main.xml


<android.support.constraint.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="com.example.bean.myapplication316v3.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Activity传递参数"
        android:textSize="30dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.109" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="姓名:"
        android:textSize="20dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.146"
        app:layout_constraintVertical_bias="0.246" />

    <TextView
        android:id="@+id/textView0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="返回的值"
        android:textSize="20dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.156"
        app:layout_constraintVertical_bias="0.791" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="进入子页面"
        android:textSize="16dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintVertical_bias="0.614" />

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="张三"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.738"
        app:layout_constraintVertical_bias="0.242" />

android.support.constraint.ConstraintLayout>

2.3 activity_main2.xml


<android.support.constraint.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="com.example.bean.myapplication316v3.Main2Activity">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:textSize="20dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintVertical_bias="0.097" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="要返回主程序的值"
        android:textSize="20dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.091"
        app:layout_constraintVertical_bias="0.242" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="返回"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.526"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="168dp"
        android:layout_height="42dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="输入返回值"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintVertical_bias="0.238"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.947"
        tools:layout_editor_absoluteY="130dp"
        tools:layout_editor_absoluteX="200dp" />
android.support.constraint.ConstraintLayout>

2.4 MainActivity.java

package com.example.bean.myapplication316v3;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText editText1 = (EditText)findViewById(R.id.editText);

        Button button1 = (Button)findViewById(R.id.button);

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent (MainActivity.this,Main2Activity.class);
                Bundle bundle = new Bundle();
                bundle.putCharSequence("name", (CharSequence) editText1.getText().toString());
                intent.putExtras(bundle);  //bundle对象添加到Intent对象
                startActivityForResult(intent,1);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //第一个参数是启动活动时传入的请求码,第二个参数就是数据传入时处理的结果,第三个参数是携带返回数据的Intent

        switch (requestCode){            //判断请求码,也就是判断是哪一个活动返回的
            case 1:
                if(resultCode == 1){        //判断返回数据传入的处理结果
                    TextView textView0 = (TextView)findViewById(R.id.textView0);
                    assert data != null;
                    textView0.setText(data.getStringExtra("edit"));
                }
                break;
            default:
        }
    }

}

2.5 Main2Activity.java

package com.example.bean.myapplication316v3;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Main2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        final EditText editText2 = (EditText)findViewById(R.id.editText2);
        TextView textView2 = (TextView)findViewById(R.id.textView2);
        Button button2 = (Button)findViewById(R.id.button2);
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        String mm = bundle.getString("name");
        textView2.setText(mm);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent (Main2Activity.this,MainActivity.class);
                Bundle bundle = new Bundle();
                bundle.putCharSequence("edit", (CharSequence) editText2.getText().toString());
                intent.putExtras(bundle);  //bundle对象添加到Intent对象
                setResult(1,intent);
                finish();
            }
        });
    }
}

2.7 总结

返回数据给上一个活动
这个就期望在活动销毁的时候能够返回一个结果给上一个活动
startactivityForResult(第一个参数还是Intent,第二个参数是请求码)//和startActivity和像,但是多了一个请求码,用于在之后的回调中判断数据来源

第一个活动
Intent intent=new Intent(FirstActivity.this,SecondActivity.class);
startActivityForResult(intent,1);

第一个活动接收下一个活动销毁后给的数据
@override
protected void onActivityResult(int requestCode,int resultCode,Intent data){            //第一个参数是启动活动时传入的请求码,第二个参数就是数据传入时处理的结果,第三个参数是携带返回数据的Intent
switch (requestCode){            //判断请求码,也就是判断是哪一个活动返回的
case 1:
if(resultCode == RESULT_OK){        //判断返回数据传入的处理结果
String resultData=data.getStringExtra("data_return");      //返回的数据
}
break;
default:
}
}

第二个活动传输数据给上一个活动
Intent intent=new Inten();          //创建一个只用于传输数据的Intent
intent.putExtra("data_return","hello firstActivity");           //要传输的数据
setResult(RESULT_OK,intent);                                    //专门向上一个活动传输数据的函数,第一个参数是处理结果,第二个参数是把带有数据的Intent传递回去
finish();

3. Activity综合练习

3.0 题目要求

  • 在主程序界面当按下游戏介绍按钮时进行游戏介绍界面,按“返回”按钮则回到主程序界面。
  • 在主程序界面按下“进入游戏”按钮则进入游戏界面,按“返回”按钮加回主界面同时将子程序界面中的游戏成绩返回到主程序并显示

3.1 效果展示

【android编程】第七讲-android Activity实践题_第5张图片
【android编程】第七讲-android Activity实践题_第6张图片
【android编程】第七讲-android Activity实践题_第7张图片
【android编程】第七讲-android Activity实践题_第8张图片

3.2 activity_main.xml


<android.support.constraint.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"
    android:background="@drawable/gameface"
    tools:context="com.example.bean.myapplication316v1.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textColor="#FF0000"
        android:textSize="36dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.881"
        app:layout_constraintHorizontal_bias="0.503"
        android:id="@+id/textView" />

    

    

    

    

android.support.constraint.ConstraintLayout>

3.4 activity_introduce.xml


<android.support.constraint.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"
    android:background="@drawable/game1"
    tools:context="com.example.bean.myapplication316v1.IntroduceActivity">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="这里是游戏介绍"
        android:textColor="#FF0000"
        android:textSize="38dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintVertical_bias="0.219" />

    
android.support.constraint.ConstraintLayout>

3.5 activity_score.xml


<android.support.constraint.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"
    android:background="@drawable/game2"
    tools:context="com.example.bean.myapplication316v1.ScoreActivity">

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="游戏成绩为3200分"
        android:textSize="38dp"
        android:textColor="#FF0000"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="16dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.513"
        app:layout_constraintVertical_bias="0.2" />

    
android.support.constraint.ConstraintLayout>

3.6 MainActivity.java

package com.example.bean.myapplication316v1;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageButton button1 = (ImageButton)findViewById(R.id.imageButton1);
        ImageButton button2 = (ImageButton)findViewById(R.id.imageButton2);

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent (MainActivity.this,IntroduceActivity.class);
                startActivity(intent);
            }
        });
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent (MainActivity.this,ScoreActivity.class);
                startActivityForResult(intent,1);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode){            //判断请求码,也就是判断是哪一个活动返回的
            case 1:
                if(resultCode == 1){        //判断返回数据传入的处理结果
                    TextView textView = (TextView)findViewById(R.id.textView);
                    assert data != null;
                    textView.setText(data.getStringExtra("score"));
                }
                break;
            default:
        }

    }
}

3.7 IntroduceActivity.java

package com.example.bean.myapplication316v1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class IntroduceActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_introduce);
        ImageButton button5 = (ImageButton)findViewById(R.id.imageButton5);
        button5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}

3.7 ScoreActivity.java

package com.example.bean.myapplication316v1;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

public class ScoreActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_score);
        ImageButton button6 = (ImageButton)findViewById(R.id.imageButton6);
        final TextView textView3 = (TextView)findViewById(R.id.textView3);
        button6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent (ScoreActivity.this,MainActivity.class);
                Bundle bundle = new Bundle();
                bundle.putCharSequence("score",textView3.getText().toString());
                intent.putExtras(bundle);
                setResult(1,intent);  //设置返回的结果码  resultCode
                finish();
            }
        });
    }
}

你可能感兴趣的:(Android)