save code
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.khronos.vulkan_samples;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SecondActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_second);
|
||||
|
||||
TextView textView = findViewById(R.id.textViewSecond);
|
||||
Button buttonBack = findViewById(R.id.buttonBack);
|
||||
|
||||
// 接收从MainActivity传递的数据
|
||||
Intent intent = getIntent();
|
||||
if (intent != null && intent.hasExtra("message")) {
|
||||
String message = intent.getStringExtra("message");
|
||||
textView.setText(message);
|
||||
}
|
||||
|
||||
buttonBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 返回数据到MainActivity
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra("returnData", "Hello back from SecondActivity!");
|
||||
setResult(RESULT_OK, returnIntent);
|
||||
|
||||
// 结束当前Activity
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user