static final int FP = ViewGroup.LayoutParams.FILL_PARENT;
static final int WC = ViewGroup.LayoutParams.WRAP_CONTENT;
- static final int AND = 0;
- static final int OR = 1;
- static final int NOT = 2;
+ static final int AND = 100;
+ static final int OR = 101;
+ static final int NOT = 102;
static final float QUESTION_TEXT_SIZE = 30.0f;
private int[] correctAnswer = { OR, AND, NOT, AND };
private int[] userAnswer = new int[QUESTION_SIZE];
private ImageView[] answerView = new ImageView[QUESTION_SIZE];
- private int[] ViewAllay = { R.drawable.and, R.drawable.or, R.drawable.not };
+ private int[] ViewArray = {R.drawable.and, R.drawable.or, R.drawable.not};
+
+ private ImageButton andBtn;
+ private ImageButton orBtn;
+ private ImageButton notBtn;
+
LinearLayout viewLayout;
private int count = 0;
}
private void createBtnArray(LinearLayout selectBtnLayout) {
- ImageButton[] btnArray = new ImageButton[3];
-
- for (int i = 0; i < btnArray.length; i++) {
- ImageButton btn = new ImageButton(cxt);
- btn.setOnClickListener(this);
- switch (i) {
- case AND: {
- btn.setImageDrawable(res.getDrawable(ViewAllay[AND]));
- btn.setId(AND);
- break;
- }
- case OR: {
- btn.setImageDrawable(res.getDrawable(ViewAllay[OR]));
- btn.setId(OR);
- break;
- }
- case NOT: {
- btn.setImageDrawable(res.getDrawable(ViewAllay[NOT]));
- btn.setId(NOT);
- break;
- }
- default: {
- }
- }
+ andBtn = new ImageButton(cxt);
+ andBtn.setOnClickListener(this);
+ andBtn.setImageDrawable(res.getDrawable(R.drawable.and));
- selectBtnLayout.addView(btn);
- }
+ orBtn = new ImageButton(cxt);
+ orBtn.setOnClickListener(this);
+ orBtn.setImageDrawable(res.getDrawable(R.drawable.or));
+
+ notBtn = new ImageButton(cxt);
+ notBtn.setOnClickListener(this);
+ notBtn.setImageDrawable(res.getDrawable(R.drawable.not));
+ selectBtnLayout.addView(andBtn);
+ selectBtnLayout.addView(orBtn);
+ selectBtnLayout.addView(notBtn);
}
private LinearLayout createAnswerLayout(Context cxt) {
} else if (count < QUESTION_SIZE) {
userAnswer[count] = v.getId();
- answerView[count].setImageDrawable(res.getDrawable(ViewAllay[v
+ answerView[count].setImageDrawable(res.getDrawable(ViewArray[v
.getId()]));
viewLayout.invalidate();
count++;