Android 传值问题

传值可以用intent 还有bundle,

我用的是bundle

在要第一个页面中

                             Intent intent=new Intent(MainActivity.this,SecondActivity.class);      
Bundle abc= new Bundle();  //实例化bundle对象
abc.putString("jiayou","加油");//在对象中添加数据
intent.putExtras(abc);//intent发送数据
startActivity(intent);


在第二个页面中:

                         Intent intent = getIntent();
                  Bundle abc = intent.getExtras();  
                    String abcd = args.getString("jiayou");
                    Textview=(TextView)findViewById(R.id.textView1);
                   Textview.setText(abcd);

                 

猜你喜欢

转载自blog.csdn.net/hey_gril/article/details/53432931
今日推荐