當一個Activity啟動另一個Activity時,常常會有一些數據傳過去,對于Activity之間的數據交換更簡單,因為兩個Activity之間進行數據傳遞交換更簡單,因為兩個Activity之間本來就有一個“信使”Intent。

創新互聯主要從事網站設計制作、做網站、網頁設計、企業做網站、公司建網站等業務。立足成都服務館陶,十多年網站建設經驗,價格優惠、服務專業,歡迎來電咨詢建站服務:028-86922220
Intent的用途其實有很多,今天用到的只是最基本的。
視頻教程:http://v.youku.com/v_show/id_XNzQxMDUxNTU2.html
http://www.iqiyi.com/w_19rsgrq0wt.html#vfrm=14-7-2-1
郵箱:whsgzcy@foxmail.com
主要是以下方法:
第一種:
intent = new Intent(MainActivity.this,Second.class);
bundle = new Bundle();
bundle.putString("nihao", ed_content.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
接收:
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
tv_show.setText(bundle.getString("nihao"));
第二種:
intent = new Intent();
intent.setClass(MainActivity.this,Second.class);
intent.putExtra("key", "dash");
startActivity(intent);
接收:
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
String name = bundle.getString("key");
tv_show.setText(name);
首先對于在API中查到的參數需要注意以下:
context : 這個參數代表了,整個android應用的接口,幾乎所有創造的組件都要用到。一般都是 類名.this
標題名稱:Android中Activity之間的數據傳遞(Intent和Bundle)
網頁鏈接:http://www.yijiale78.com/article40/gdcseo.html
成都網站建設公司_創新互聯,為您提供、面包屑導航、建站公司、外貿建站、網站策劃、做網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯