0

I want to know how to drop the probability in android of a random text, which already has been used, while the other ones keep theirs. So I have this code here and now I'm asking for a solution for my problem.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="name">
        <item>One</item>
        <item>Two</item>
        <item>Three</item>
    </string-array>

    <string name="app_name">Drink</string>
</resources>

partymodus.java

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.Random;

public class partymodus extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_partymodus);

        final TextView aufgabe=(TextView)findViewById(R.id.txt_aufgabe);
        final Button next =  (Button)findViewById(R.id.btn_next);

        next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
                String[] aufgaben = getResources().getStringArray(R.array.name);
                Random rand = new Random();
                int n = rand.nextInt(aufgaben.length - 0) + 0;
                aufgabe.setText(aufgaben[n]);

            }
        });
    }
}
VenomVendor
  • 15,064
  • 13
  • 65
  • 96
Frezoki
  • 47
  • 6
  • 1
    Note: your question doesn't seem to be spesific to Android Studio in any way. The question seems to be about an Android app. Android Studio is just an IDE commonly used for Android app dev. – hyde Feb 10 '19 at 21:36
  • It is a bit unclear what are you asking for, but I think I answered similar question before (Python though). Could you please take a look at https://stackoverflow.com/questions/53544961/how-do-i-randomly-equalize-unequal-values/ and tell me if it is the same/similar question? – Severin Pappadeux Feb 11 '19 at 15:48
  • No, I want a Text which has already appeared less likely to appear again. So that the probability of that sinks. – Frezoki Feb 13 '19 at 09:40

0 Answers0