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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何從字符串?dāng)?shù)組中獲取字符串以便它可以與 SetText 一起使用?安卓工作室

如何從字符串?dāng)?shù)組中獲取字符串以便它可以與 SetText 一起使用?安卓工作室

寶慕林4294392 2021-09-03 15:14:14
我正在做一個(gè)測(cè)驗(yàn)應(yīng)用程序,在不同的章節(jié)中有很多問題。當(dāng)然每一章都是一個(gè)數(shù)組。但是現(xiàn)在,我已經(jīng)到了需要一個(gè)特定章節(jié)來從所有章節(jié)中提取所有問題和答案的地步。所以基本上它是另一個(gè)數(shù)組中的一個(gè)數(shù)組。 public void shuffleChapterRandomTest() {    shuffledPositionChapterRandomTest = new String[chapterRandomTestQuestions.length];    for (int k = 0; k < shuffledPositionChapterRandomTest.length; k++) {        shuffledPositionChapterRandomTest[k] = String.valueOf(k);    }    Collections.shuffle(Arrays.asList(shuffledPositionChapterRandomTest));    Log.i("TAG", "shuffle: " + shuffledPositionChapterRandomTest[0] + " " + shuffledPositionChapterRandomTest[1]);}public static String shuffledPositionChapterRandomTest[];private String chapterRandomTestQuestions[][] = { //This are all the chapters being called        Questions,        chapterTwoQuestions,        chapterThreeQuestions,        chapterFourQuestions,        chapterFiveQuestions,        chapterSixQuestions,        chapterSevenQuestions,        chapterEightQuestions,        chapterNineQuestions,        chapterTenQuestions,        chapterElevenQuestions,        chapterTwelveQuestions,        chapter13Questions,        chapter14Questions};//This is my get methodpublic String[] getChapterRandomTestQuestion(String a) {    return chapterRandomTestQuestions[Integer.parseInt(a)];}當(dāng)我嘗試從“問題”中提取字符串作為 TextView 的 setText 時(shí)。 private void updateQuestion() {    if (questionnumber < questionBank.getChapterRandomTestLength()) {        storeUserData.setInt(Constants.TOTAL_QUESTION,questionBank.getChapterRandomTestLength());        binding.tvCountQuestion.setText(questionnumber+1+"/"+questionBank.getChapterRandomTestLength());它顯示一個(gè)錯(cuò)誤:必需:Java.lang.String 找到:Java.lang.String[]如何將問題和答案提取為字符串而不是數(shù)組。謝謝!
查看完整描述

1 回答

?
慕桂英4014372

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超13個(gè)贊

你打電話時(shí)

questionBank.getChapterRandomTestQuestion(shuffledPositionChapterRandomTest[questionnumber])

您正在檢索String[],代表 中的條目之一chapterRandomTestQuestions。你需要使用

questionBank.getChapterRandomTestQuestion(shuffledPositionChapterRandomTest[questionnumber])[someNumber]

另外,我注意到您正在填充shuffledPositionChapterRandomTest整數(shù)的字符串表示。為什么不int[]改為使用它,并避免必須轉(zhuǎn)換為 String 然后再轉(zhuǎn)換回 int?

另一個(gè)注釋/問題:我認(rèn)為您可能為數(shù)組編寫了錯(cuò)誤的內(nèi)容。語(yǔ)法是

SomeObject[] variable

不是

SomeObject variable[]


查看完整回答
反對(duì) 回復(fù) 2021-09-03
  • 1 回答
  • 0 關(guān)注
  • 183 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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