Advertisement
delvinkrasniqi

Buton Enable- checkbox

Nov 28th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package com.example.butoncheckbox;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4.  
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.CheckBox;
  9.  
  10. public class MainActivity extends AppCompatActivity {
  11. CheckBox checkbx;
  12. Button button;
  13. @Override
  14. protected void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. setContentView(R.layout.activity_main);
  17.  
  18. checkbx=(CheckBox)findViewById(R.id.checkBox);
  19. button=(Button)findViewById(R.id.button);
  20.  
  21. checkbx.setOnClickListener(new View.OnClickListener() {
  22. @Override
  23. public void onClick(View v) {
  24. Boolean gjendja=checkbx.isChecked();
  25.  
  26. if(gjendja)
  27. button.setEnabled(true);
  28. else
  29. button.setEnabled(false);
  30. }
  31. });
  32.  
  33.  
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement