Here are the examples of the java api class android.support.v7.widget.AppCompatCheckBox taken from open source projects.
1. GittyReporter#onCreate()
Project: GittyReporter
File: GittyReporter.java
File: GittyReporter.java
@Override protected final void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gitty_reporter_layout); // Get Device info and print them in EditText deviceInfoEditText = (EditText) findViewById(R.id.gittyreporter_device_info); getDeviceInfo(); deviceInfoEditText.setText(deviceInfo); init(savedInstanceState); final View nextFab = findViewById(R.id.gittyreporter_fab_next); final View sendFab = findViewById(R.id.gittyreporter_fab_send); if (!enableGitHubLogin) { nextFab.setVisibility(View.INVISIBLE); sendFab.setVisibility(View.VISIBLE); } AppCompatCheckBox githubCheckbox = (AppCompatCheckBox) findViewById(R.id.gittyreporter_github_checkbox); AppCompatButton registerButton = (AppCompatButton) findViewById(R.id.gittyreporter_github_register); final EditText userName = (EditText) findViewById(R.id.gittyreporter_login_username); final EditText userPassword = (EditText) findViewById(R.id.gittyreporter_login_password); userPassword.setTypeface(Typeface.DEFAULT); userPassword.setTransformationMethod(new PasswordTransformationMethod()); if (!enableGuestGitHubLogin) { githubCheckbox.setChecked(false); githubCheckbox.setVisibility(View.GONE); registerButton.setVisibility(View.VISIBLE); } githubCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { userName.setEnabled(false); userName.setText(""); userPassword.setEnabled(false); userPassword.setText(""); } else { userName.setEnabled(true); userPassword.setEnabled(true); } } }); }