我是安卓新手。
我面临数组列表的问题。问题是..
我的数组是字符串数组列表。我需要的是什么?我有两个数组列表。QtnsArraylist1 包含 4.. 元素(4.. 问题), AnsArraylist2 包含 16.. 元素(16.. 答案,每个问题 4 个选项总共 16.. 元素)。对于 QtnsArraylist1 中的第一个问题,我必须获得前 4 个元素来自 AnsArraylist2。类似地,如果我给下一个按钮,它会显示问题 2、3、4...。我怎么能得到这个?.
请帮我一个..
提前致谢。
protected void onPostExecute(String file_url) {
pDialog.dismiss();
ques1=new ArrayList<String>(new HashSet<String>(ques1));
System.out.println(" Question array:"+ques1);
String[] quesArr = new String [ques1.size()];
quesArr = ques1.toArray(quesArr);
for(String s: quesArr){
System.out.println("All Array Questions:"+s);
final TextView txtque = (TextView) findViewById(R.id.que_txt);
final String text=ques1.get(j).toString();
System.out.println("Array:"+text);
txtque.setText(text);
}
answ1=new ArrayList<String>(new ArrayList<String>(answ1));
System.out.println(" Answer array:"+answ1);
String[] answArr = new String [answ1.size()];
answArr = answ1.toArray(answArr);
for(String A: answArr){
// final Object getName0 = answArr[0].toString();
// final Object getName1 = answArr[1].toString();
// final Object getName2 = answArr[2].toString();
// final Object getName3 = answArr[3].toString();
Collections.sort(answ1, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);
}
});
System.out.println("All Array Answers:"+A);
}
btn_practicerg =(RadioGroup) findViewById(R.id.rdgroup);
btn_practice1 = (RadioButton) findViewById(R.id.RB1);
btn_practice1.setText(String.valueOf(answArr[0]));
btn_practice2 = (RadioButton) findViewById(R.id.RB2);
btn_practice2.setText(String.valueOf(answArr[1]));
btn_practice3 = (RadioButton) findViewById(R.id.RB3);
btn_practice3.setText(String.valueOf(answArr[2]));
btn_practice4 = (RadioButton) findViewById(R.id.RB4);
btn_practice4.setText(String.valueOf(answArr[3]));
Button nextBtn = (Button) findViewById(R.id.nxt_btn);
nextBtn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
j++;
TextView txtque = (TextView) findViewById(R.id.que_txt);
txtque.setText(ques1.get(j).toString());
k++;
btn_practice1.setText(answ1.get(k).toString());
k++;
btn_practice2.setText(answ1.get(k).toString());
k++;
btn_practice3.setText(answ1.get(k).toString());
k++;
btn_practice4.setText(answ1.get(k).toString());