Java Code Examples for android.support.v7.widget.AppCompatCheckBox#setChecked()
The following examples show how to use
android.support.v7.widget.AppCompatCheckBox#setChecked() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiChoiceDialog.java From AssistantBySDK with Apache License 2.0 | 6 votes |
private void init() { mRgChoice.setVisibility(View.GONE); mChoiceBox.setVisibility(View.VISIBLE); mCdTitle.setText(title); for (int i = 0; i < datas.length; i++) { AppCompatCheckBox cb = new AppCompatCheckBox(mContext); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-1, ScreenUtil.getInstance().dip2px(48)); cb.setLayoutParams(layoutParams); cb.setGravity(Gravity.CENTER_VERTICAL); cb.setId(i); cb.setText(datas[i]); cb.setTextSize(15); cb.setTextColor(mContext.getResources().getColor(R.color.new_text_color_first)); cb.setPadding(ScreenUtil.getInstance().dip2px(16), 0, 0, 0); if (i == 0) cb.setChecked(true); mChoiceBox.addView(cb); } }
Example 2
Source File: EssMediaAdapter.java From FilePicker with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, EssFile item) { if (item.getItemType() == EssFile.CAPTURE) { helper.getView(R.id.media).setVisibility(View.GONE); helper.getView(R.id.capture).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(mImageResize- UiUtils.dpToPx(mContext,4), mImageResize)); helper.addOnClickListener(R.id.capture); } else { helper.getView(R.id.capture).setVisibility(View.GONE); helper.getView(R.id.media).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mImageResize)); ImageView imageView = helper.getView(R.id.media_thumbnail); RequestOptions options = new RequestOptions() .centerCrop() .override(mImageResize, mImageResize) .placeholder(SelectOptions.getInstance().placeHolder == null ? mContext.getResources().getDrawable(R.mipmap.png_holder) : SelectOptions.getInstance().placeHolder); Glide .with(mContext) .load(item.getUri()) .apply(options) .into(imageView); if(SelectOptions.getInstance().isSingle || SelectOptions.getInstance().maxCount == 1){ helper.setVisible(R.id.check_view,false); }else { AppCompatCheckBox checkBox = helper.getView(R.id.check_view); helper.setVisible(R.id.check_view,true); helper.addOnClickListener(R.id.check_view); helper.addOnClickListener(R.id.media_thumbnail); checkBox.setChecked(item.isChecked()); } } }
Example 3
Source File: KcaResoureLogFragment.java From kcanotify_h5-master with GNU General Public License v3.0 | 5 votes |
public View setView(final View v) { Log.e("KCA", "setView " + position); v.setTag("fragment_view"); v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_box_%d", position), R.id.class)).setVisibility(View.VISIBLE); v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_box_%d", 1 - position), R.id.class)).setVisibility(GONE); for (int i = 0; i < 4; i++) { final int k = i; AppCompatCheckBox box = v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_%d_%d", position, i), R.id.class)); box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { is_draw_enabled[k] = b; setChartDataVisibility(v, k); } }); box.setChecked(is_draw_enabled[k]); } ((TextView) v.findViewById(R.id.reslog_item_label_0)).setText(getStringWithLocale(R.string.reslog_label_date)); if (position == 0) { ((TextView) v.findViewById(R.id.reslog_item_label_1)).setText(getStringWithLocale(R.string.item_fuel)); ((TextView) v.findViewById(R.id.reslog_item_label_2)).setText(getStringWithLocale(R.string.item_ammo)); ((TextView) v.findViewById(R.id.reslog_item_label_3)).setText(getStringWithLocale(R.string.item_stel)); ((TextView) v.findViewById(R.id.reslog_item_label_4)).setText(getStringWithLocale(R.string.item_baux)); } else { ((TextView) v.findViewById(R.id.reslog_item_label_1)).setText(getStringWithLocale(R.string.item_bgtz)); ((TextView) v.findViewById(R.id.reslog_item_label_2)).setText(getStringWithLocale(R.string.item_brnr)); ((TextView) v.findViewById(R.id.reslog_item_label_3)).setText(getStringWithLocale(R.string.item_mmat)); ((TextView) v.findViewById(R.id.reslog_item_label_4)).setText(getStringWithLocale(R.string.item_kmat)); } ListView resource_data = v.findViewById(R.id.reslog_listview); resource_data.setAdapter(adapter); adapter.notifyDataSetChanged(); drawChart(v); return v; }
Example 4
Source File: EssMediaAdapter.java From AndroidDownload with Apache License 2.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, EssFile item) { if (item.getItemType() == EssFile.CAPTURE) { helper.getView(R.id.media).setVisibility(View.GONE); helper.getView(R.id.capture).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(mImageResize- UiUtils.dpToPx(mContext,4), mImageResize)); helper.addOnClickListener(R.id.capture); } else { helper.getView(R.id.capture).setVisibility(View.GONE); helper.getView(R.id.media).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mImageResize)); ImageView imageView = helper.getView(R.id.media_thumbnail); RequestOptions options = new RequestOptions() .centerCrop() .override(mImageResize, mImageResize) .placeholder(SelectOptions.getInstance().placeHolder == null ? mContext.getResources().getDrawable(R.mipmap.png_holder) : SelectOptions.getInstance().placeHolder); Glide .with(mContext) .load(item.getUri()) .apply(options) .into(imageView); if(SelectOptions.getInstance().isSingle || SelectOptions.getInstance().maxCount == 1){ helper.setVisible(R.id.check_view,false); }else { AppCompatCheckBox checkBox = helper.getView(R.id.check_view); helper.setVisible(R.id.check_view,true); helper.addOnClickListener(R.id.check_view); helper.addOnClickListener(R.id.media_thumbnail); checkBox.setChecked(item.isChecked()); } } }
Example 5
Source File: MultiChoiceQuestionBody.java From ResearchStack with Apache License 2.0 | 5 votes |
private View initViewDefault(LayoutInflater inflater, ViewGroup parent) { RadioGroup radioGroup = new RadioGroup(inflater.getContext()); radioGroup.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); radioGroup.setDividerDrawable(ContextCompat.getDrawable(parent.getContext(), R.drawable.rsb_divider_empty_8dp)); for (int i = 0; i < choices.length; i++) { Choice<T> item = choices[i]; // Create & add the View to our body-view AppCompatCheckBox checkBox = (AppCompatCheckBox) inflater.inflate(R.layout.rsb_item_checkbox, radioGroup, false); checkBox.setText(item.getText()); checkBox.setId(i); radioGroup.addView(checkBox); // Set initial state if (currentSelected.contains(item.getValue())) { checkBox.setChecked(true); } // Update result when value changes checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { currentSelected.add(item.getValue()); } else { currentSelected.remove(item.getValue()); } }); } return radioGroup; }
Example 6
Source File: FTPServerFragment.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
private void initLoginDialogViews(View loginDialogView) { usernameEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_username); passwordEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_password); usernameTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_username); passwordTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_password); mAnonymousCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_anonymous); mSecureCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_secure); mAnonymousCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { usernameEditText.setEnabled(false); passwordEditText.setEnabled(false); } else { usernameEditText.setEnabled(true); passwordEditText.setEnabled(true); } } }); // init dialog views as per preferences if (getUsernameFromPreferences().equals(FTPService.DEFAULT_USERNAME)) { mAnonymousCheckBox.setChecked(true); } else { usernameEditText.setText(getUsernameFromPreferences()); passwordEditText.setText(getPasswordFromPreferences()); } if (getSecurePreference()) { mSecureCheckBox.setChecked(true); } else { mSecureCheckBox.setChecked(false); } // check if we have a keystore InputStream stream = getResources().openRawResource(R.raw.explorer); if (stream == null) { mSecureCheckBox.setEnabled(false); mSecureCheckBox.setChecked(false); setSecurePreference(false); } }
Example 7
Source File: CreateConnectionFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); final LayoutInflater dialogInflater = getActivity().getLayoutInflater(); final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false); name = (AppCompatEditText) view.findViewById(R.id.name); host = (AppCompatEditText) view.findViewById(R.id.host); port = (AppCompatEditText) view.findViewById(R.id.port); path = (AppCompatEditText) view.findViewById(R.id.path); hostContainer = view.findViewById(R.id.hostContainer); pathContainer = view.findViewById(R.id.pathContainer); username = (AppCompatEditText) view.findViewById(R.id.username); usernameContainer = view.findViewById(R.id.usernameContainer); password = (AppCompatEditText) view.findViewById(R.id.password); passwordContainer = view.findViewById(R.id.passwordContainer); scheme = (AppCompatSpinner) view.findViewById(R.id.scheme); anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous); anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE); passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE); } }); if(connection_id != 0){ NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id); ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter(); int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase()); scheme.setSelection(spinnerPosition); name.setText(connection.getName()); host.setText(connection.getHost()); port.setText(Integer.toString(connection.getPort())); path.setText(connection.getPath()); username.setText(connection.getUserName()); password.setText(connection.getPassword()); anonymous.setChecked(connection.isAnonymousLogin()); if(SERVER.equals(connection.getType())){ hostContainer.setVisibility(View.GONE); pathContainer.setVisibility(View.VISIBLE); } } builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection"); builder.setView(view); builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final BaseActivity activity = (BaseActivity) getActivity(); NetworkConnection networkConnection = getNetworkConnection(); if(validate(networkConnection)){ new CreateConnectionTask(activity, networkConnection).executeOnExecutor( ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY)); } } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
Example 8
Source File: CreateConnectionFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); final LayoutInflater dialogInflater = getActivity().getLayoutInflater(); final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false); name = (AppCompatEditText) view.findViewById(R.id.name); host = (AppCompatEditText) view.findViewById(R.id.host); port = (AppCompatEditText) view.findViewById(R.id.port); path = (AppCompatEditText) view.findViewById(R.id.path); hostContainer = view.findViewById(R.id.hostContainer); pathContainer = view.findViewById(R.id.pathContainer); username = (AppCompatEditText) view.findViewById(R.id.username); usernameContainer = view.findViewById(R.id.usernameContainer); password = (AppCompatEditText) view.findViewById(R.id.password); passwordContainer = view.findViewById(R.id.passwordContainer); scheme = (AppCompatSpinner) view.findViewById(R.id.scheme); anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous); anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE); passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE); } }); if(connection_id != 0){ NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id); ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter(); int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase()); scheme.setSelection(spinnerPosition); name.setText(connection.getName()); host.setText(connection.getHost()); port.setText(Integer.toString(connection.getPort())); path.setText(connection.getPath()); username.setText(connection.getUserName()); password.setText(connection.getPassword()); anonymous.setChecked(connection.isAnonymousLogin()); if(SERVER.equals(connection.getType())){ hostContainer.setVisibility(View.GONE); pathContainer.setVisibility(View.VISIBLE); } } builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection"); builder.setView(view); builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final BaseActivity activity = (BaseActivity) getActivity(); NetworkConnection networkConnection = getNetworkConnection(); if(validate(networkConnection)){ new CreateConnectionTask(activity, networkConnection).executeOnExecutor( ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY)); } } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
Example 9
Source File: CreateConnectionFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); final LayoutInflater dialogInflater = getActivity().getLayoutInflater(); final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false); name = (AppCompatEditText) view.findViewById(R.id.name); host = (AppCompatEditText) view.findViewById(R.id.host); port = (AppCompatEditText) view.findViewById(R.id.port); path = (AppCompatEditText) view.findViewById(R.id.path); hostContainer = view.findViewById(R.id.hostContainer); pathContainer = view.findViewById(R.id.pathContainer); username = (AppCompatEditText) view.findViewById(R.id.username); usernameContainer = view.findViewById(R.id.usernameContainer); password = (AppCompatEditText) view.findViewById(R.id.password); passwordContainer = view.findViewById(R.id.passwordContainer); scheme = (AppCompatSpinner) view.findViewById(R.id.scheme); anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous); anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE); passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE); } }); if(connection_id != 0){ NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id); ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter(); int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase()); scheme.setSelection(spinnerPosition); name.setText(connection.getName()); host.setText(connection.getHost()); port.setText(Integer.toString(connection.getPort())); path.setText(connection.getPath()); username.setText(connection.getUserName()); password.setText(connection.getPassword()); anonymous.setChecked(connection.isAnonymousLogin()); if(SERVER.equals(connection.getType())){ hostContainer.setVisibility(View.GONE); pathContainer.setVisibility(View.VISIBLE); } } builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection"); builder.setView(view); builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final BaseActivity activity = (BaseActivity) getActivity(); NetworkConnection networkConnection = getNetworkConnection(); if(validate(networkConnection)){ new CreateConnectionTask(activity, networkConnection).executeOnExecutor( ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY)); } } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
Example 10
Source File: GittyReporter.java From GittyReporter with Apache License 2.0 | 4 votes |
@Override final protected 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); } } } ); }