android的Activity之间的数据传递(2)
25 System.out.println("这里已经执行...");
26 String txt = "";
27 Bundle extras = data.getExtras();
28 if(extras != null){
29 txt = extras.getString("store");
30 }
31 setTitle("这里是</SPAN><SPAN style="FONT-SIZE: 13px; LINE-HEIGHT: 19px; FONT-FAMILY: 'sans serif', tahoma, verdana, helvetica; WHITE-SPACE: normal; BACKGROUND-COLOR: #ffffff">Activity1</SPAN><SPAN>:" + txt);
32 }
33 }
34 }</SPAN></P>
这是Activity2中的代码:
view sourceprint?01 <SPAN>@Override
02 protected void onCreate(Bundle savedInstanceState) {
03 super.onCreate(savedInstanceState);
04 setTitle("这是activity2");
05 setContentView(R.layout.layout2);
06 Bundle bundle = getIntent().getExtras();
07 if(bundle != null){
08 setTitle("这里是Activity2:" + bundle.getString("</SPAN><SPAN style="LINE-HEIGHT: 19px">activity1</SPAN>"));<SPAN> }
09
10 Button btn = (Button) findViewById(R.id.btn2);
11 btn.setOnClickListener(new Button.OnClickListener() {
12 @Override
13 public void onClick(View v) {
14 Bundle bundle = new Bundle();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>