• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Ask user to select a random letter

Hi,

I need to ask a user to select a random letter from the alphabet and then display a success or fail notation if they choose the correct letter.

At the moment I have the code asking to choose a letter using audio when a button is clicked.

Has anyone any advice or can point me in the direction to get some?

Any help is greatly appreciated.
 
Last edited:
At the moment I have a button when pressed asks the user to pick a random letter. What I need is for the user to select the letter that was asked and if they guess correct they get a "Well done" message and if fail asked to try again.
This example only has 6 letters in it.

Code:
//On click for the button random letter message

public void onClickRandom(View v){
    int rando = (int) (Math.random()*6);
    if(rando == 1){
        play_s.start();
    }else if (rando ==2){
        play_t.start();
    }else if (rando ==3){
        play_p.start();
    }else if (rando ==4){
        play_i.start();
    }else if (rando ==5){
        play_n.start();
    }else {
        play_a.start();
    }

}
 
Upvote 0
Sorry still a bit confused as to what you are asking here. The above code appears to play one of six audio files at random.
Are you asking how to allow the user to enter a letter? For that you will need an EditText component, which is pretty simple.
How do you wish to display the 'well done' message? Could be in a popup dialog, or a text box.
 
Upvote 0
The user just needs to select a letter. Please see they attached. It might clear it up a bit.

Pop up dialogue and play a sound would be what I am aiming for.
 

Attachments

  • Untitled.png
    Untitled.png
    77.4 KB · Views: 56
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones