package com.example.wuzuo.myapplication1;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.CDCS).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Main2Activity.class);//当前Activity.this, 要打开的Activity.class
i.putExtra("date","hahahhahahahhahahahhahahahhahahahha");
startActivity(i);
}
});
}
}
package com.example.wuzuo.myapplication1;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class Main2Activity extends AppCompatActivity {
private TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Intent i=getIntent();
tv=findViewById(R.id.tv);
tv.setText(i.getStringExtra("date"));
}
}