码迷,mamicode.com
首页 > 其他好文 > 详细

Activity间传参

时间:2016-06-05 18:44:37      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

技术分享技术分享技术分享

 1 package com.example.metrox.l3;
 2 
 3 import android.content.Intent;
 4 import android.support.v7.app.AppCompatActivity;
 5 import android.os.Bundle;
 6 import android.view.View;
 7 
 8 public class MainActivity extends AppCompatActivity {
 9 
10     @Override
11     protected void onCreate(Bundle savedInstanceState) {
12         super.onCreate(savedInstanceState);
13         setContentView(R.layout.activity_main);
14         findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
15             @Override
16             public void onClick(View view) {
17                 startActivity(new Intent(MainActivity.this,TheAty.class).putExtra("data","http://www.cnblogs.com/linhongquan"));
18             }
19         });
20     }
21 }
 1 package com.example.metrox.l3;
 2 
 3 import android.support.v7.app.AppCompatActivity;
 4 import android.os.Bundle;
 5 import android.widget.TextView;
 6 
 7 public class TheAty extends AppCompatActivity {
 8 
 9     @Override
10     protected void onCreate(Bundle savedInstanceState) {
11         super.onCreate(savedInstanceState);
12         setContentView(R.layout.activity_the_aty);
13         ((TextView)findViewById(R.id.textView2)).setText(getIntent().getStringExtra("data"));
14     }
15 }

 

Activity间传参

标签:

原文地址:http://www.cnblogs.com/linhongquan/p/5561241.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!