Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.butoncheckbox;
- import androidx.appcompat.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.CheckBox;
- public class MainActivity extends AppCompatActivity {
- CheckBox checkbx;
- Button button;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- checkbx=(CheckBox)findViewById(R.id.checkBox);
- button=(Button)findViewById(R.id.button);
- checkbx.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Boolean gjendja=checkbx.isChecked();
- if(gjendja)
- button.setEnabled(true);
- else
- button.setEnabled(false);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement