作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我正在尝试制作一个测验 Android 应用程序。我正在尝试显示用户在另一项 Activity 中出错的问题和多项选择。我不知道如何转移多个错题。
这是我的测验 java 类。
public class QuizActivityMarketing extends Activity{
private Iterator<Question> questionIterator;
private TextView txtQuestion;
private RadioButton rda, rdb, rdc, rdd;
public Button butNext;
private int qid = 0;
private Question currentQ;
private int score = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
// Define your views
txtQuestion = (TextView) findViewById(R.id.textView1);
rda = (RadioButton) findViewById(R.id.radio0);
rdb = (RadioButton) findViewById(R.id.radio1);
rdc = (RadioButton) findViewById(R.id.radio2);
rdd = (RadioButton) findViewById(R.id.radio3);
butNext = (Button) findViewById(R.id.button1);
//Log question and option if wrong
TextView question = (TextView) findViewById(R.id.textView1);
RadioButton optA = (RadioButton) findViewById(R.id.radio0);
RadioButton optB = (RadioButton) findViewById(R.id.radio1);
RadioButton optC = (RadioButton) findViewById(R.id.radio2);
RadioButton optD = (RadioButton) findViewById(R.id.radio3);
if (!currentQ.getANSWER().trim().equals(answer.getText())) {
Log.d("Current Question", ""+question.getText());
Log.d("OptionA", ""+optA.getText());
Log.d("OptionB", ""+optB.getText());
Log.d("OptionC", "" + optC.getText());
Log.d("OptionD", "" + optD.getText());
}
// Load the next question, if there are any
if (questionIterator.hasNext()) {
currentQ = questionIterator.next();
setQuestionView(currentQ);
qid++;
}
// Done asking questions
Intent intent1 = getIntent();
int buttonValue = Integer.valueOf(intent1.getExtras().getString("button"));
if (qid > buttonValue)
{
这是我的结果类
public class ResultActivityMarketing extends AppCompatActivity {
//get text view for score
TextView testResult = (TextView) findViewById(R.id.testResult);
//get score
Bundle extras = getIntent().getExtras();
if (extras != null) {
int score = extras.getInt("score");
int numberquestions = extras.getInt("button");
testResult.setText("You got " + score + " out of " + numberquestions + " questions correct");
}
}
}
这是我的结果 Activity 的 XML 类。
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/wrong_questions_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Wrong Questions"
android:paddingTop="10dp"/>
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.04" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:layout_marginTop="30dp"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton"/>
</RadioGroup>
</FrameLayout>
</ScrollView>
</LinearLayout>
谁能帮帮我。我真的很感激。我不知道该怎么做。提前致谢!
我是一名优秀的程序员,十分优秀!