- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainactivity.java
More file actions
Latest commit
37 lines (30 loc) · 1.16 KB
/
Copy pathmainactivity.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
packagecom.example.unitconverter;
importandroidx.appcompat.app.AppCompatActivity;
importandroid.os.Bundle;
importandroid.view.View;
importandroid.widget.Button;
importandroid.widget.EditText;
importandroid.widget.TextView;
importandroid.widget.Toast;
publicclassMainActivityextendsAppCompatActivity {
privateButtonbutton;
privateTextViewtextView;
privateEditTextedittext;
@Override
protectedvoidonCreate(BundlesavedInstanceState) {
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(newView.OnClickListener() {
@Override
publicvoidonClick(Viewview) {
Toast.makeText(MainActivity.this, "Hello you have submitted your query", Toast.LENGTH_SHORT).show();
Strings= edittext.getText().toString();
intkg= Integer.parseInt(s);
doublepound= 2.205*kg;
textView.setText("The corresponding value of KG to pound is" + pound);
} });
}
}