-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeActivity.java
More file actions
49 lines (40 loc) · 1.49 KB
/
HomeActivity.java
File metadata and controls
49 lines (40 loc) · 1.49 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
38
39
40
41
42
43
44
45
46
47
48
49
package com.example.a52weeksaveapplast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class HomeActivity extends AppCompatActivity {
private EditText principle;
private TextView savedAmount;
private Button calculate, reset;
int principleAmount;
int savedAmt;
int weeks;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
principle = (EditText) findViewById(R.id.edittxtPri);
savedAmount = (TextView) findViewById(R.id.savedAmt);
calculate = (Button) findViewById(R.id.calculateBt);
calculate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
principleAmount = Integer.parseInt(principle.getText().toString());
savedAmt = 26*52*principleAmount;
savedAmount.setText(savedAmt);
}
});
reset = (Button) findViewById(R.id.reset);
reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
principle.setText(" ");
savedAmount.setText(" ");
}
});
}
}