How to randomize a RadioButton?

44
February 12, 2019, at 01:50 AM

I'm trying to make a multiple choice quiz. I have a problem when I want to get a multiple choice button randomly. I wonder how to randomize the position of the multiple choice button. This is an example of my multiple choice button code.

       rb1.setText(currentQuestion.getOption1());
        rb2.setText(currentQuestion.getOption2());
        rb3.setText(currentQuestion.getOption3());

I want to make randomize for example:

rb2.setText(currentQuestion.getOption1());
rb3.setText(currentQuestion.getOption2());
rb1.setText(currentQuestion.getOption3());
Answer 1

add question to array list and then shuffle it. Later take read it from index 0.

    ArrayList arrayList = new ArrayList();
    arrayList.add("Q1");
    arrayList.add("Q2");
    arrayList.add("Q3");
    Collections.shuffle(arrayList);
    // set array list items to radio buttons
READ ALSO
Image Asset requirements

Image Asset requirements

I am trying to create Adaptive Launcher Icons in Android StudioThe result is a my image rendered as a small icon with lots of padding within a circular Launch Icon

50
pi zero w web server / access point - Failed to obtain IP address on android

pi zero w web server / access point - Failed to obtain IP address on android

After a month of trying, i now have a pi zero w as a standalone web server running nginxApple devices can join the AP Wifi (no internet) and using

27
android : How is the default value assigned during insert in room

android : How is the default value assigned during insert in room

I am using Room in my app and while testing migrations i did a direct insert ( not using the Entity class )

44