T
T
troffee2015-04-11 09:32:52
Android
troffee, 2015-04-11 09:32:52

Showing a random word how to implement?

I want that after entering any word and pressing the "OK" button, there will be an output to the TextView of two words, the one that was written and the one that is stored as a variable (database of words).
Here is the code, what should I change in it?

public void onClick(View view) {
        if (editText.getText().length() == 0) {
            textResult.setText("Введите слово!");
        } else {
            textResult.setText(editText.getText()+ "Сюда нужно вывести слово из базы");
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2015-04-11
@IceJOKER

public static int randInt(int min, int max) {

    // NOTE: Usually this should be a field rather than a method
    // variable so that it is not re-seeded every call.
    Random rand = new Random();

    // nextInt is normally exclusive of the top value,
    // so add 1 to make it inclusive
    int randomNum = rand.nextInt((max - min) + 1) + min;

    return randomNum;
}

stackoverflow.com/questions/363681/generating-rand...
^^^
Then I think you can handle it yourself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question