3.15
安卓
• 所花时间:1
• 代码行数:321
• 博客容量:1
• 代码如下:
<?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=".recieveAct"
android:orientation="vertical">
<TextView
android:id="@+id/tv_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="今天天气真不错!"
android:textSize="30sp"/>
<Button
android:id="@+id/bt_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="发送以上文字"/>
</LinearLayout>
package com.example.chapter05;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class recieveAct extends AppCompatActivity implements View.OnClickListener {
private TextView tv_send;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recieve);
tv_send= findViewById(R.id.tv_send);
findViewById(R.id.bt_send).setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent =new Intent(this, sendAct.class);
Bundle bundle =new Bundle();
bundle.putString("request_content",tv_send.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
}
}
浙公网安备 33010602011771号