歡迎訂閱杜仲教學頻道: https://www.youtube.com/channel/UCElwt6s8Ea_V-gnu9sZZT5g?sub_confirmation=1 杜仲教學部落格: https://derekcctu.blogspot.com/
2018年10月30日 星期二
[Android]_ch6.2_傳遞資料給其他活動
在Intent物件攜帶傳遞資料是使用Bundle物件,它是一種目錄物件(Dictionary Object,儲存鍵與值的對應資料),可以儲存字串型態鍵值對應的各種資料型態資料,如下所示:
//1.建立Intent物件
Intent myIntent = new Intent();
//2.藉由setClass()方法設定來源與目的地類別
myIntent.setClass(First.this, Second.class);
//3.建立Bundle物件,利用putString(鍵值,資料)方法新增字串資料
Bundle bundle = new Bundle();
bundle.putString("HEIGHT", height.getText().toString());
bundle.putString("WEIGHT“, weight.getText().toString());
//4.使用Intenet物件的puExtras()方法,附加Bundle物件
myIntent.putExtras(bundle);
//5.啟動活動
startActivity(myIntent);
訂閱:
張貼留言 (Atom)
Ether.fi Cash Card 一張所有人必備的加密貨幣信用卡 [Ether.fi Cash Card] : https://www.ether.fi/app/cash/sign-up?ref_code=d27f8523 ------國際交易所------ [Bitg...
-
22.Hamster Kombat Daily Combo倉鼠戰鬥_DailyCombo0620 ------國際交易所------ [Bitget 交易所]: https://partner.bitget.com/bg/DCA888 邀請碼:DCA888 [Bybit交...
-
[CATS coin每日任務(Ton區塊鏈游戲伏擊百倍幣)] https://t.me/catsgang_bot/join?startapp=FXvTt0OIdo7NJ4jxDutEV ------國際交易所------ [Bitget 交易所]: https://partn...
沒有留言:
張貼留言