Android界面跳轉與數據傳遞

第一個Activity:FirstActivity

                      Bundle bundle = new Bundle();

                   //保存id
                    bundle.putInt("id", comment.getId());
                    Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
                    intent.putExtra("bundle", bundle);

                    //跳轉
                    startActivity(intent);


第二個Activity:     SecondActivity

            //取出傳過來的id

              Bundle bundle = this.getIntent().getBundleExtra("bundle");
              int  id = bundle.getInt("id");


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章