0
I’m trying to set the variable txtMedia1 with the value of the variable media1. I did so, but the Android Studio indicates that I have to change txtMedia1 to double or media1 for TextView:
package com.app.jeffersonalencar.composicao;
import android.renderscript.Double2;
import android.renderscript.Sampler;
import android.support.annotation.StringDef;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Button;
import android.widget.TextView;
public class act_mains extends AppCompatActivity implements View.OnClickListener{
    //Declarando variáveis de coleta de medida
    public EditText edtTxt1, edtTxt2, edtTxt3;
    //Declarando campo de visualização da média por parte
    public TextView txtMedia1;
    //Declarando botão
    public Button btnMedia1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_main);
        //Setando os valores dos campos de coleta para as variáveis
        edtTxt1 = (EditText) findViewById(R.id.edtTxt1);
        edtTxt2 = (EditText) findViewById(R.id.edtTxt2);
        edtTxt3 = (EditText) findViewById(R.id.edtTxt3);
    }
    public void onClick(View V){
        double medida1 = Double.parseDouble(edtTxt1.getText().toString());
        double medida2 = Double.parseDouble(edtTxt2.getText().toString());
        double medida3 = Double.parseDouble(edtTxt3.getText().toString());
        double media1 = (medida1 + medida2 + medida3)/3;
        //Terminar a briga e colocar o valor no TextView
        String media2 = String.valuesOf(media1);
        txtMedia1 = (TextView) getText(R.id.media2) ;
    }
}
Realizing what the Android Studio still asks yes of error.
Now after pressing the calculation button the application closes.. @Ack Lay public void onClick(View V){ double medida1 = Double.parseDouble(edtTxt1.gettext(). toString(); double medida2 = Double.parseDouble(edtTxt2.gettext(). toString(); double medida3 = Double.parseDouble(edtTxt3.gettext(). toString(); double Bicipalmedia = (measure1 + measure2 + measure3)/3; //End the fight and put the value in Textview String valueDouble= Double.toString(Bicipalmedia); txtMedia1.setText(valueDouble);
– Jefferson Alencar