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:
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
.