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.
Thanks!!

Code:

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 sammie38
2 hours ago
Last post by antwan.moen
2 hours ago
Last post by daniela21
1 hour ago
Last post by prince42
3 hours ago
Last post by ereynolds
2 hours ago
Last post by miguel.stamm
3 hours ago
Last post by jany91
1 hour ago
Last post by emile.goyette
3 hours ago
Last post by jaylin.upton
1 hour ago
Last post by ekoch
4 hours ago
Last post by kunde.melyssa
2 hours ago