第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 Android Studio 3.4 中將字符串值從一個 Activity 發(fā)送到另一個

在 Android Studio 3.4 中將字符串值從一個 Activity 發(fā)送到另一個

哈士奇WWW 2023-07-13 13:53:16
請設(shè)計一個android應(yīng)用程序,我想將(5)字符串值從一個活動發(fā)送到另一個活動以在不同的TextView中使用,我?guī)缀鯂L試了我可以在網(wǎng)上找到的有關(guān)該主題的所有代碼,但我一直只得到一個值(我在 putExtra() 中發(fā)送的最后一個值)。我是 Android Studio 的新手,非常感謝您的每一個幫助。我已經(jīng)使用 putExtra() 將一個數(shù)據(jù)發(fā)送到另一個活動,并且它工作得很好,在嘗試對多個數(shù)據(jù)執(zhí)行相同操作時,我總是只收到發(fā)送的數(shù)據(jù)之一。我還嘗試使用捆綁對象來接收來自其他(接收)活動的數(shù)據(jù)。我希望在另一個活動中獲取所有這些數(shù)據(jù)(intent.putExtra("surname", "Jerry"). intent.putExtra("middlename", "chris").intent.putExtra("lastname", "Enema")),但我一直只得到“灌腸”這是我的代碼;//在第一個Activity中     send.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                String sFirstname = firstname.getText().toString();                String sLastname = lastname.getText().toString();                Intent intent = new Intent(MainActivity.this, ReceiveActivity.class);                intent.putExtra("surname" ,sFirstname);                intent.putExtra("lastname", sLastname);                startActivity(intent);            }        });//And In the second Activity名字 = findViewById(R.id.名字); 姓氏 = findViewById(R.id.firstname);Intent intent = getIntent();Bundle bundle = getIntent().getExtras();String ssurname = bundle.getString("surname");String slastname = bundle.getString("lastname");firstname.setText(ssurname);lastname.setText(slastname);
查看完整描述

2 回答

?
慕少森

TA貢獻2019條經(jīng)驗 獲得超9個贊

嘗試這個。在第一個活動中:


String sFirstname = "Tope";

String sLastname = "Adebodun";


Intent theIntent = new Intent(MainActivity.this, ReceivingActivity.class);

theIntent.putExtra("firstname", sFirstname);

theIntent.putExtra("lastname", sLastname);

然后在第二個活動中,在 onCreate 方法中執(zhí)行以下操作:


Intent intent = getIntent();

String thefirst = (String) intent.getExtras.getString("firstname");

String thelast = (String) intent.getExtras.getString("lastname");


查看完整回答
反對 回復 2023-07-13
?
UYOU

TA貢獻1878條經(jīng)驗 獲得超4個贊

我不想使用getExtras所以你應(yīng)該有兩個getExtra 像這樣的:


 Intent intent = getIntent();


 String ssurname = intent.getExtra("surname");

 String slastname = intent.getExtra("lastname");


 firstname.setText(ssurname);

 lastname.setText(slastname);


查看完整回答
反對 回復 2023-07-13
  • 2 回答
  • 0 關(guān)注
  • 153 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號