我有这个想要首先看不见的imageView ...然后当我点击一个按钮(calculateButton)时,imageView将是可见的.
这是我的ImageView:
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/resultLabel"
android:layout_below="@+id/resultLabel"
android:src="@drawable/image" />
Run Code Online (Sandbox Code Playgroud)
这是我的calculateButton代码:
public void calculateClickHandler(View view) {
if (view.getId() == R.id.calculateButton) {
EditText weightText = (EditText) findViewById(R.id.weightText);
EditText heightText = (EditText)findViewById(R.id.heightText);
TextView resultText = (TextView)findViewById(R.id.resultLabel);
int weight = (int) Float.parseFloat(weightText.getText().toString());
int height = (int) Float.parseFloat(heightText.getText().toString());
int bmiValue = calculateBMI(weight, height);
String bmiInterpretation = interpretBMI(bmiValue);
resultText.setText("Your BMI is:" + " " + bmiValue + " " + bmiInterpretation); }
}
private int calculateBMI (int weight, int height) {
return (int) weight …Run Code Online (Sandbox Code Playgroud)