Getting constant false value from method

前端 未结 3 507
迷失自我
迷失自我 2021-01-21 17:42

I have 3 questions

 private static int NUMBER_OF_QUESTIONS = 3;
static boolean[] answer = new boolean[NUMBER_OF_QUESTIONS];
static boolean[] checked = new boolea         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-21 18:28

    Try this:

    static boolean[] isAnswered = new boolean[NUMBER_OF_QUESTIONS]; // initially all false
    
    .............
    ....................
    
    rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.radioButton1) {
                Toast.makeText(getActivity(), "True", Toast.LENGTH_SHORT).show();
                checked[0] = true;
                answer[0] = true;
            } else {
                checked[0] = true;
                answer[0] = false;
            }
    
            // Update value as user selected radio button
            isAnswered[0] = true;
        }
    });
    

    Do same for your other RadioGroups(rg2, rg3, ......). Hope this will help~

提交回复
热议问题