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]);
}
});
}
}