本帖最後由 黃茂勛 於 2018-8-25 11:49 編輯
- package com.example.student.myapplication;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.widget.EditText;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity {
- EditText input;
- TextView result;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- input = (EditText) findViewById(R.id.input);
- result = (TextView) findViewById(R.id.result);
- }
- public void click(View view) {
- Log.d("Einsteinlog", "welcome");
- int num = Integer.parseInt(input.getText().toString());
- double rs = num*3.3058;
- result.setText("面積為: "+String.valueOf(rs)+"平方公尺");
- }
- public void clean(View view) {
- Log.i("Albertlog","hello");
- input.setText("");
- result.setText("");
- }
- }
複製代碼 |