Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.mathapplication;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.CheckBox;
- import android.widget.SeekBar;
- import android.widget.TextView;
- import android.widget.Toast;
- import androidx.appcompat.app.AppCompatActivity;
- public class SettingsActivity extends AppCompatActivity {
- SeekBar skbMin, skbMax;
- TextView tvMin, tvMax;
- CheckBox chkAdd, chkSub, chkMul, chkDiv;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_settings);
- skbMin = findViewById(R.id.skbMin);
- skbMax = findViewById(R.id.skbMax);
- tvMin = findViewById(R.id.tvMin);
- tvMax = findViewById(R.id.tvMax);
- chkAdd = findViewById(R.id.chkAdd);
- chkSub = findViewById(R.id.chkSub);
- chkMul = findViewById(R.id.chkMul);
- chkDiv = findViewById(R.id.chkDiv);
- skbMin.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- tvMin.setText("min = " + progress);
- }
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
- });
- skbMax.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- tvMax.setText("max = " + progress);
- }
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
- });
- skbMin.setProgress(Settings.min);
- skbMax.setProgress(Settings.max);
- chkAdd.setChecked(Settings.add);
- chkSub.setChecked(Settings.sub);
- chkMul.setChecked(Settings.mul);
- chkDiv.setChecked(Settings.div);
- }
- public void saveSettingsCLicked(View view) {
- Settings.min = skbMin.getProgress();
- Settings.max = skbMax.getProgress();
- Settings.add = chkAdd.isChecked();
- Settings.sub = chkSub.isChecked();
- Settings.mul = chkMul.isChecked();
- Settings.div = chkDiv.isChecked();
- Settings.saveSettings(this);
- Toast.makeText(this, "Settings saved successfully !!!", Toast.LENGTH_LONG).show();
- finish();
- }
- public void cancelClicked(View view) {
- finish();
- }
- }
Add Comment
Please, Sign In to add comment