0
package com.example.testetrabalho;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
//variaveis
EditText editTextValorG;
EditText editTextValorL;
EditText editTextValorP;
Button btnCalcula;
private EditText textViewMostra;
private TextView textViewtMostra;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editTextValorG = (EditText) findViewById(R.id.editTextValorG);
editTextValorL = (EditText) findViewById(R.id.editTextValorL);
editTextValorP = (EditText) findViewById(R.id.editTextValorP);
// textViewMostra = (TextView) findViewById(R.id.textViewMostra);
btnCalcula = (Button) findViewById(R.id.btnCalcula);
//funçao do botao calcular
btnCalcula.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
double valorG = Double.parseDouble(editTextValorL.getText().toString());
double valorL = Double.parseDouble(editTextValorL.getText().toString());
double valorP = Double.parseDouble(editTextValorP.getText().toString());
//IF
if ((valorG < valorL) && (valorG < valorP))
textViewMostra.setText(valorG);
else if ((valorL < valorG) && (valorL < valorP))
textViewMostra.setText(valorL);
else if ((valorP < valorG) && (valorP < valorL))
textViewMostra.setText(valorP);
}
});
}
}
It would help if you put together the error messages and value of stack trace. But looking over try this here
textViewMostra.setText(String.valueOf(valorG));
or else on the linedouble valorG = Double.parseDouble(editTextValorL.getText().toString());
change toString valorG = editTextValorL.getText();
and do the same forvalorL
andvalorP
. Also to question the need for variablesvalorG
,valorL
andvalorP
in your code as you can do 'textViewMostra.setText(editTextValorL.gettext();' and the same withvalorL
andvalorP
.– Augusto Vasques
I’ll adjust it, thanks.
– Deborah Fontoura Déby
The error that gives would be read in the variables between() the if gets the red dashes below and says Cannot resolve method 'setText(double)'
– Deborah Fontoura Déby
This error is happening because setText does not accept a double, see here the accepted types https://developer.android.com/reference/android/widget/TextView.html#setText
– rnd_rss