vendredi 22 janvier 2021

How can I get random questions in Arraylist?

I have a question application and the questions always come in the same order. How can I change this? Below is my code:

Since I do not know the coding, I have added most of my code below.

QuestionsModelClass if necessary, I will add.

    list = new ArrayList<>();
        list.add(new questionsModelClass("Makalat", "Yunus Emre", "Hacı Bektaş Veli", "Sultan Veled", "Gülşehri", "Hacı Bektaş Veli"));
        list.add(new questionsModelClass("Kitabü’l Fevalit", "Ali Şir Nevai", "Fuzuli", "Katip Çelebi", "Hacı Bektaş Veli", "Hacı Bektaş Veli"));
        list.add(new questionsModelClass("Fatiha Tasviri", "Yirmisekiz Çelebi Mehmet", "Hacı Bektaş Veli", "Haliloğlu Yahya", "Yunus Emre", "Hacı Bektaş Veli"));
        list.add(new questionsModelClass("Risaletü’n Nushiye", "Yunus Emre", "Şeyyad Hamza", "Seydi Ali Reis", "Kayıkçı Kul Mustafa", "Yunus Emre"));
        list.add(new questionsModelClass("Divan", "Koçi Bey", "Nizami", "Fuzuli", "Yunus Emre", "Yunus Emre"));
        list.add(new questionsModelClass("Müzekki’n Nüfuz", "Taşlıcalı Yahya Bey", "Ali Şir Nevai", "Eşrefoğlu Rumi ", "Kaygusuz Abdal", "Eşrefoğlu Rumi "));
       


 for (int i = 0; i < 4; i++) {
            linearLayout1.getChildAt(i).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    checkAns((Button) v);
                }
            });
        }

        txtnumberIndicator.setText(position + 1 + "/" + list.size());

        playAnim(txtQuestions, 0, list.get(position).getQuestions());
        Next_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Next_btn.setEnabled(false);
                Next_btn.setAlpha(0.7f);
                enableOptions(true);
                position++;
              if  (position == list.size()) {
                    //Score Activities
                   if (score >=0) {
                        {
                        // buttons code!(i delete it)
                      }
                return;
            }
                count = 0;
                playAnim(txtQuestions, 0, list.get(position).getQuestions());
            }
        });

        navigationDrawer();
    }



Aucun commentaire:

Enregistrer un commentaire