2
I’m creating a game at Android Studio and I need to compare if the text on the screen is that or not, to then present the tip.
Ps: When using the equals
get everything true by showing the message always, which is not what I want.
Private String[] obj = { bola, sapato, caderno }
Private String[] dica = { redondo, preto, folhas }
novoobj.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Random randomico = new Random();
int objaleatorio = randomico.nextInt(perguntas.length);
textoobj.setText(obj[objaleatorio]);
novadica.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Random randomico = new Random();
int dicaaleatoria = randomico.nextInt(dica.length);
textodica.setText(dica[dicaaleatoria]);
Here comes the if
that is not working. I want only if the obj
position apart 0
, he throws the hint. But in this case below throws with any value I put. I have tried to put the text too, but gave error in Java.
if (!(obj.equals(0)){
textodica.setText(dica[dicaaleatoria]);
That is, what I want, if text on the screen is ball for example then write the random hint. Round, for example.
You can share the entire class that is this stretch ?
– fabioxd20