Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.os.Bundle;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- import androidx.activity.EdgeToEdge;
- import androidx.appcompat.app.AppCompatActivity;
- import androidx.core.graphics.Insets;
- import androidx.core.view.ViewCompat;
- import androidx.core.view.WindowInsetsCompat;
- public class MainActivity extends AppCompatActivity {
- private static boolean isHooverOn = false;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- EdgeToEdge.enable(this);
- setContentView(R.layout.activity_main);
- ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
- Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
- v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
- return insets;
- });
- EditText programInput = this.findViewById(R.id.program_input);
- TextView programDisplay = this.findViewById(R.id.washing_display);
- Button washingMachineButton = this.findViewById(R.id.washing_button);
- washingMachineButton.setOnClickListener((current) -> {
- try {
- int program = Integer.parseInt(programInput.getText().toString());
- if(program >= 1 && program <= 12) {
- programDisplay.setText("Numer prania: "+program);
- }
- } catch (Exception ignored) {
- }
- });
- Button hooverButton = this.findViewById(R.id.hoover_toggle);
- TextView enabledText = this.findViewById(R.id.hoover_state);
- hooverButton.setOnClickListener(v -> {
- isHooverOn = !isHooverOn;
- if(isHooverOn) {
- enabledText.setText("Odkurzacz włączony");
- hooverButton.setText("WYŁĄCZ");
- } else {
- enabledText.setText("Odkurzacz wyłączony");
- hooverButton.setText("WŁĄCZ");
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement