-2
 public void submit(View view){
    EditText editHeight = (EditText)findViewById(R.id.height_text_view);
    String height = editHeight.getText().toString();
    int finalHeight = Integer.parseInt(height);

    EditText editField = (EditText)findViewById(R.id.weight_text_view);
    String weight = editField.getText().toString();
    int finalWeight =Integer.parseInt(weight);

    int calc = calculate(finalHeight, finalWeight);
    displayMessage(calc);

}

public void displayMessage(int message){

    TextView result = (TextView) findViewById(R.id.result_text_view);
    result.setText(message);
}
private int calculate(int height, int weight){

    return weight * height;

I am new to android so please give me detailed info abt the sollution. here are my error details:

  • Welcome, please read [https://stackoverflow.com/help/how-to-ask](how to ask). please replace the image and share the error log in the way it should be. In addition, please add more information like XML and what are you exceptions from this code. – Dor Jul 12 '20 at 14:25
  • What kind of exception did you get? Provide us with exception message and stack trace. – Dmitry Stepanov Jul 12 '20 at 17:10

1 Answers1

0

In displayMessage method, write

result.setText(String.valueOf(message));

You set the calculated integer value to TextView but this value should be a String. If you set as an integer, it means you set the String Resource ID likes R.string.app_name.