没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Android APP编写简单答题器编写简单答题器
主要为大家详细介绍了Android APP编写简单答题器,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文为大家分享了Android APP编写的简单答题器,此答题器可以通过Next按钮选择下一题,新写题目的类Question,有两个成
员变量。
java代码:
package com.android.testrecord;
/**
* Created by wang on 16-10-19.
*/
public class Question {
private int mTextResId;
private boolean mAnswerTrue;
public Question(int textResId, boolean answerTrue) {
mTextResId = textResId;
mAnswerTrue = answerTrue;
}
public int getTextResId() {
return mTextResId;
}
public boolean isAnswerTrue() {
return mAnswerTrue;
}
public void setTextResId(int textResId) {
mTextResId = textResId;
}
public void setAnswerTrue(boolean answerTrue) {
mAnswerTrue = answerTrue;
}
}
java代码:
package com.android.testrecord;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class QuizActivity extends AppCompatActivity {
private Button mTrueButton;
private Button mFalseButton;
private Button mNextButton;
private TextView mQuestionTextView;
private Question[] mQuestionBank = new Question[] {
new Question(R.string.question_oceans, true),
new Question(R.string.question_mideast, false),
new Question(R.string.question_africa, false),
new Question(R.string.question_americas,true),
new Question(R.string.question_asia, true),
};
private int mCurrentIndex = 0;
private void updateQuestion() {
int question = mQuestionBank[mCurrentIndex].getTextResId();
mQuestionTextView.setText(question);
}
private void checkAnswer(boolean userProessedTrue) {
boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue();
int messageId = 0;
if (userProessedTrue == answerIsTrue)
messageId = R.string.correct_toast;
else
messageId = R.string.incorrect_toast;
资源评论
weixin_38739900
- 粉丝: 4
- 资源: 929
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功