- This event has passed.
7 PM – Intro To Java – Darin
September 9, 2024 @ 7:00 pm - 8:00 pm
Today We Did:
- Continued in Android Studio, implementing the function for the convert button.
- Learnt how to grab UI elements in code by id, and manipulate them using getText and setText.
Homework:
- Complete the method below inside of MainActivity.java: Grab the other EditText UI element and use .setText() on it to set it with the calculated value for the Celsius.
public void convertButtonOnClick(View view) {
// findViewById will grab the UI (user interface) element by its ID
EditText originalTempValue = findViewById(R.id.originalTempValue);
String originalTempStr = originalTempValue.getText().toString();
// Double.parseDouble(string value)
// String.valueOf( int/double value )
// convert the String originalTempStr to a double, and then
// convert it to its celsius version with the formula:
// celsius = (fahrenheit - 32) * 5/9
// and then, GRAB the other EditText and name it convertedTempValue, and use
// convertedTempValue.setText( celsius (as a string) )
System.out.println(originalTempStr);
}
Notes:
Email me at ddjapri@ayclogic.com if you have any questions.