mardi 24 novembre 2015

Set Random Text To Multiple TextView Without Any Repetition

Hello Guys I am New to Android. I am developing an App but stuck here. I want to set Random Text to TextView and I did it successfully but I am getting same text on all textview I put it. I want if the text set to one textview should not be show to other means its should not be repeat. Any help must be appreciated. I am posting some code here.

int[] array_set_up_text;
Random rand_set_up_text;

rand_set_up_text = new Random();
    array_set_up_text = new int[] { R.string.set_up_text1,  R.string.set_up_text2, R.string.set_up_text3,
            R.string.set_up_text4, R.string.set_up_text5, R.string.set_up_text6, R.string.set_up_text7,
             R.string.set_up_text8,R.string.set_up_text9,R.string.set_up_text10,R.string.set_up_text11,R.string.set_up_text12};
    rand_text_set_up = rand_set_up_text.nextInt(array_set_up_text.length - 1);

text1.setText(array_set_up_text[rand_text_set_up]);
text2.setText(array_set_up_text[rand_text_set_up]);
text3.setText(array_set_up_text[rand_text_set_up]);




Aucun commentaire:

Enregistrer un commentaire