Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid - checkbox and string[]
    primarykey
    data
    text
    <p>Sorry for seem making so clumpsy for the below code. To sum up, I am making a quiz game where user can choose 4 kinds of difficulties of the Question. if user choose checkbox 1 and 3, for example, the below code is intended to store string arrays from the string.xml into String[] NUM_ALL_QuestionNames. </p> <pre><code>//same for checkbox1,2,3, so here not duplicate // if (checkbox4=="yes") { NUM_EXP_QuestionNames = getResources().getStringArray(R.array.Num_Q_Expert_List); NUM_EXP_AnswerNames = getResources().getStringArray(R.array.Num_A_Expert_List); QuestionImport= 0; QuestionImport = NUM_EXP_QuestionNames.length; int i =0; while (i&lt;QuestionImport) { String Q_toimport = NUM_EXP_QuestionNames[i]; String A_toimport = NUM_EXP_AnswerNames[i]; NUM_ALL_QuestionNames.add(Q_toimport); NUM_ALL_AnswerNames.add(A_toimport); ++i; } }; NUM_ALLL_QuestionNames = new String[NUM_ALL_QuestionNames.size()]; //convert ArrayList&lt;String&gt; to String[] NUM_ALLL_AnswerNames = new String[NUM_ALL_AnswerNames.size()]; //convert ArrayList&lt;String&gt; to String[] </code></pre> <p>At last NUM_ALL_Questionnames would be converted back from ArrayList NUM_ALLL_QuestionNames to String[] for further processing.</p> <p>The files in the string.xml should have no problem because when I try set as follows (directly extract from the string.xml) the apps runs fine:</p> <pre><code>NUM_ALLL_QuestionNames = getResources().getStringArray(R.array.Num_Q_Simple_List); NUM_ALLL_AnswerNames = getResources().getStringArray(R.array.Num_A_Simple_List); </code></pre> <h2>Question:</h2> <ol> <li><p>Now is it data from string.xml in String[] format, it was then added to the List, where this List at last convert back to String[]. Are there any modification such that is no need this conversion. It is better if string.xml can be directly to String[]</p></li> <li><p>When goes on executeing the app, logcat does not show any error. However, the Emulator keep black screen. Why does it happen? Are there any endless loop for the Code?</p></li> </ol> <p>Many thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload