-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainactivity.java
More file actions
37 lines (30 loc) · 1.16 KB
/
mainactivity.java
File metadata and controls
37 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.example.unitconverter;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private Button button;
private TextView textView;
private EditText edittext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=findViewById(R.id.button);
textView=findViewById(R.id.textView);
edittext=findViewById(R.id.edittext);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Hello you have submitted your query", Toast.LENGTH_SHORT).show();
String s= edittext.getText().toString();
int kg= Integer.parseInt(s);
double pound= 2.205*kg;
textView.setText("The corresponding value of KG to pound is" + pound);
} });
}
}