- public class MainActivity extends AppCompatActivity {
- TextView tv;
- EditText et;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- et = (EditText)findViewById(R.id.et);
- tv = (TextView)findViewById(R.id.textView4);
- }
- public void deletefun(View view) {
- Log.d("delete","clear");
- tv.setText("");
- et.setText("");
- }
- public void changefun(View view) {
- Log.d("change","finish");
- int input = Integer.parseInt(et.getText().toString());
- double res = input*3.3058;
- tv.setText(String.valueOf(res));
- }
- }
- [code]
複製代碼 [/code] |