Hello all,

I'm trying to write a Random Words Generator App. I am just starting out and I have read a little and watched a few tutorials. What I have so far is the main.xml file that has my layout. It has a 2 TextViews (Left TextView & Right TextView), and 2 buttons (Left Spin & Right Spin)

Where I'm at... I click the Left Button, the screen flashes and then displays a random Word. But then that's it, I can not click it or any other button again. They do nothing until I hit the back button, which displays the main screen again as if I never clicked anything. Then, and only then, I can click a button only once until I go back.

Here is my code for the Left side. I have another class for the Right side that is the same.

I was hoping someone could tell me what I am doing wrong.


import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.widget.TextView; import java.util.Random;

public class LeftSideWord extends Activity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btnls = (Button) findViewById(R.id.btLeftSpin); btnls.setOnCreateContextMenuListener(this); Random generator = new Random(); int num; String[] lword; lword= new String[5]; lword[0]= "Word1"; lword[1]= "Word2"; lword[2]= "Word3"; lword[3]= "Word4"; lword[4]= "Word5"; TextView tvLeft = (TextView) findViewById(R.id.tvLeftWord); num=generator.nextInt(5); tvLeft.setText(lword[num]); } }

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by aledner
2 hours ago
Last post by nathan46
2 hours ago
Last post by gmosciski
55 minutes ago
Last post by fay.malachi
4 hours ago