自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Android程序開發(fā)基礎之——頁面?zhèn)髦?/h1>

移動開發(fā) Android
Android程序開發(fā)基礎。

Activity跳轉(zhuǎn)與傳值,主要是通過Intent類來連接多個Activity,通過Bundle類來傳遞數(shù)據(jù)。

示例代碼如下:

1.1、使用intent.putExtra()方法賦值

 

[[73022]]

 

1 public class menu extends Activity {

2

3 @Override

4 public void onCreate(Bundle savedInstanceState) {

5 super.onCreate(savedInstanceState);

6

7 setContentView(R.layout.menu);

8

9 ...

10

11 // Button2

12 Button Btn2 = (Button) findViewById(R.id.button2);

13

14 Btn2.setOnClickListener(new OnClickListener() {

15

16 @Override

17 public void onClick(View arg0) {

18

19 Intent intent = new Intent(menu.this, detail.class);

20 intent.putExtra("flg", "list");

21 startActivity(intent);

22 }

23 });

24

25 ...

26

27

28 }

 

[[73022]]

 

1.2、在另一個頁面獲取傳值

1 Bundle bundle = this.getIntent().getExtras();

2 String flg = bundle.getString("flg");

3 if (flg.equals("list")) {

4 ...

5 }

2.1、如果要傳遞的是一組數(shù)據(jù)的話,就要借助Bundle對象來傳遞數(shù)據(jù)了。

 

[[73022]]

 

1 Bundle bundle = new Bundle();

2

3 bundle.putString("Name", "Jacker");

4 bundle.putString("Phone", "13590010101");

5 bundle.putBoolean("flg", true);

6

7 intent.putExtras(bundle);

 

[[73022]]

 

2.2獲取傳值的方法相同

1 Bundle bundle = this.getIntent().getExtras();

2

3 String name = bundle.getString("Name");

4 String phone = bundle.getString("Phone");

5 boolean flg = bundle.getBoolean("flg");

【編輯推薦】

  1. 谷歌推新版Android地圖:可看餐館內(nèi)全景圖
  2. Google爭取Android控制權(quán) 摩托羅拉是其殺手锏
  3. 產(chǎn)品交互設計:iPhone和Android的控件對比
責任編輯:冰凝兒 來源: 博客園
相關(guān)推薦

2012-05-14 21:08:47

Android頁面布局

2013-07-24 16:47:23

iOS開發(fā)學習iOS協(xié)議代理傳值

2009-07-06 10:00:31

JSP頁面?zhèn)髦?/a>

2011-05-19 17:49:08

ActivityAndroid開發(fā)

2010-05-22 16:57:09

BlackBerry開

2024-07-03 08:04:34

2010-05-11 16:55:12

Windows Pho

2009-08-14 17:08:00

Android應用程序

2010-01-25 15:15:46

Android傳值

2013-07-05 15:05:42

Windows PhoWP頁面間傳值方法

2009-07-24 14:36:10

ASP.NET跨頁面?zhèn)?/a>

2016-11-04 10:47:27

微信小程序

2013-01-17 15:51:42

Android開發(fā)應用程序組件

2013-06-03 10:22:41

iOS開發(fā)移動開發(fā)頁面間傳值

2011-07-25 18:32:55

iPad 平板電腦 蘋果

2009-07-14 15:42:38

MyEclipse開發(fā)

2011-04-11 10:06:16

傳值傳引用

2011-05-31 13:34:22

應用開發(fā)iPad

2017-09-08 16:45:14

移動

2021-12-03 09:49:59

鴻蒙HarmonyOS應用
點贊
收藏

51CTO技術(shù)棧公眾號