List of usage examples for android.widget CheckBox CheckBox
public CheckBox(Context context)
From source file:Main.java
private static CheckBox createCheckBox(Context context, String text) { CheckBox checkBox = new CheckBox(context); checkBox.setText(text);//w ww . j a v a 2 s.com checkBox.setChecked(false); return checkBox; }
From source file:com.ducnd.dialogs.AboutDialog.java
/** * @see DialogFragment#onCreateDialog(Bundle) */// ww w .j a va 2 s. c o m @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final CheckBox checkBox = new CheckBox(getActivity()); checkBox.setText("Don't show"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { checkBox.setTextColor(Color.WHITE); } return new AlertDialog.Builder(getActivity()).setTitle("About").setMessage("About Message") .setView(checkBox).setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PreferencesManager.getInstance(getActivity()).setShowAbout(!checkBox.isChecked()); } }).setNegativeButton("Visit 47deg", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = "http://47deg.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).setNeutralButton("Go to GitHub", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = "https://github.com/47deg/android-swipelistview"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).create(); }
From source file:idv.qin.dialog.AboutDialog.java
/** * @see android.support.v4.app.DialogFragment#onCreateDialog(android.os.Bundle) *///from w ww . j a v a2 s . co m @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final CheckBox checkBox = new CheckBox(getActivity()); checkBox.setText("dontShow"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { checkBox.setTextColor(Color.WHITE); } return new AlertDialog.Builder(getActivity()).setTitle("about").setMessage("aboutMessage").setView(checkBox) .setPositiveButton("ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PreferencesManager.getInstance(getActivity()).setShowAbout(!checkBox.isChecked()); } }).setNegativeButton("visit47", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = "http://47deg.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).setNeutralButton("goToGitHub", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = "https://github.com/47deg/android-swipelistview"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).create(); }
From source file:com.cummins.mowo.activity.swipelistview.AboutDialog.java
/** * @see android.support.v4.app.DialogFragment#onCreateDialog(android.os.Bundle) *///from w ww . j ava 2 s . c o m @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final CheckBox checkBox = new CheckBox(getActivity()); checkBox.setText(R.string.dontShow); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { checkBox.setTextColor(Color.WHITE); } return new AlertDialog.Builder(getActivity()).setTitle(R.string.about).setMessage(R.string.aboutMessage) .setView(checkBox).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PreferencesManager.getInstance(getActivity()).setShowAbout(!checkBox.isChecked()); } }).setNegativeButton(R.string.visit47, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = "http://47deg.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).setNeutralButton(R.string.goToGitHub, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = "https://github.com/47deg/android-swipelistview"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).create(); }
From source file:ly.apps.android.rest.client.example.dialogs.AboutDialog.java
/** * @see android.support.v4.app.DialogFragment#onCreateDialog(android.os.Bundle) *///from w w w .j a va2 s .c o m @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final CheckBox checkBox = new CheckBox(getActivity()); checkBox.setText(R.string.dontShow); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { checkBox.setTextColor(Color.WHITE); } return new AlertDialog.Builder(getActivity()).setTitle(R.string.about).setMessage(R.string.aboutMessage) .setView(checkBox).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PreferencesManager.getInstance(getActivity()).setShowAbout(!checkBox.isChecked()); } }).setNegativeButton(R.string.visit47, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = getString(R.string.fourty_seven_website); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).setNeutralButton(R.string.goToGitHub, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String url = getString(R.string.android_rest_github_url); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }).create(); }
From source file:com.javielinux.dialogs.CreateDefaultColumnsUserDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { userId = getArguments().getLong("user_id"); userEntity = new Entity("users", userId); CharSequence[] choices = new CharSequence[3]; choices[0] = getString(R.string.timeline); choices[1] = getString(R.string.mentions); choices[2] = getString(R.string.direct_messages); final boolean[] isChoices = new boolean[] { true, true, true }; LinearLayout llTitle = new LinearLayout(getActivity()); llTitle.setOrientation(LinearLayout.VERTICAL); final CheckBox boxInvite = new CheckBox(getActivity()); boxInvite.setText(R.string.follow_tweettopics); boxInvite.setChecked(true);//from w w w . j a v a 2 s . c om llTitle.addView(boxInvite); TextView txtTitle = new TextView(getActivity()); txtTitle.setText(R.string.create_columns); txtTitle.setTextSize(25); llTitle.addView(txtTitle); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setCustomTitle(llTitle); builder.setMultiChoiceItems(choices, isChoices, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { isChoices[whichButton] = isChecked; } }); builder.setCancelable(false); builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // choices int count = DataFramework.getInstance().getEntityListCount("columns", "") + 1; if (isChoices[0]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_TIMELINE); Entity timeline = new Entity("columns"); timeline.setValue("description", type.getString("description")); timeline.setValue("type_id", type); timeline.setValue("position", count); timeline.setValue("user_id", userEntity.getId()); timeline.save(); count++; } if (isChoices[1]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_MENTIONS); Entity mentions = new Entity("columns"); mentions.setValue("description", type.getString("description")); mentions.setValue("type_id", type); mentions.setValue("position", count); mentions.setValue("user_id", userEntity.getId()); mentions.save(); count++; } if (isChoices[2]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_DIRECT_MESSAGES); Entity dms = new Entity("columns"); dms.setValue("description", type.getString("description")); dms.setValue("type_id", type); dms.setValue("position", count); dms.setValue("user_id", userEntity.getId()); dms.save(); } ((TweetTopicsActivity) getActivity()).refreshColumns(); // create friend if (boxInvite.isChecked()) { Utils.showMessage(getActivity(), getActivity().getString(R.string.thanks)); new Thread(new Runnable() { @Override public void run() { try { ConnectionManager.getInstance().getTwitter(userEntity.getId()) .createFriendship("tweettopics_app"); } catch (TwitterException e1) { e1.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } } }).start(); } } }); return builder.create(); }
From source file:com.loopj.android.http.sample.DirectorySample.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Button deleteTargetFile = new Button(this); deleteTargetFile.setText(R.string.button_delete_target_file); deleteTargetFile.setOnClickListener(new View.OnClickListener() { @Override/*from w ww . ja v a 2 s . c o m*/ public void onClick(View v) { clearOutputs(); if (lastResponseHandler != null) { File toBeDeleted = lastResponseHandler.getTargetFile(); debugResponse(LOG_TAG, String.format("File was deleted? %b", toBeDeleted.delete())); debugResponse(LOG_TAG, String.format("Delete file path: %s", toBeDeleted.getAbsolutePath())); } else { debugThrowable(LOG_TAG, new Error("You have to Run example first")); } } }); cbAppend = new CheckBox(this); cbAppend.setText("Constructor \"append\" is true?"); cbAppend.setChecked(false); cbRename = new CheckBox(this); cbRename.setText("Constructor \"renameTargetFileIfExists\" is true?"); cbRename.setChecked(true); customFieldsLayout.addView(deleteTargetFile); customFieldsLayout.addView(cbAppend); customFieldsLayout.addView(cbRename); }
From source file:org.telegram.ui.Cells.CheckBoxCell.java
public CheckBoxCell(Context context) { super(context); if (paint == null) { paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.divider)); paint.setStrokeWidth(1);/*from w w w .j a v a2s . co m*/ } textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 17 : 46), 0, (LocaleController.isRTL ? 46 : 17), 0)); valueTextView = new TextView(context); valueTextView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent)); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setEllipsize(TextUtils.TruncateAt.END); valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 17, 0, 17, 0)); checkBox = new CheckBox(context); checkBox.setClickable(false); checkBox.setFocusable(false); checkBox.setBackground(null); addView(checkBox, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, (LocaleController.isRTL ? 0 : 7), 0, (LocaleController.isRTL ? 7 : 0), 0)); }
From source file:nz.ac.auckland.lablet.script.components.TextComponent.java
@Override public View createView(Context context, android.support.v4.app.Fragment parent) { CheckBox view = new CheckBox(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.setTextAppearance(android.R.style.TextAppearance_Medium); view.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color, null)); } else {/*from w w w . j a va 2 s. c o m*/ view.setTextAppearance(context, android.R.style.TextAppearance_Medium); view.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color)); } view.setText(text); if (getState() == ScriptTreeNode.SCRIPT_STATE_DONE) view.setChecked(true); view.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { if (checked) setState(ScriptTreeNode.SCRIPT_STATE_DONE); else setState(ScriptTreeNode.SCRIPT_STATE_ONGOING); } }); return view; }
From source file:com.odoo.base.login_signup.SyncWizard.java
private void generateLayout() { LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.layoutLoginConfig); SyncWizardValues syncValues = new SyncWizardValues(); List<SyncValue> syncValuesList = syncValues.syncValues(); if (syncValuesList.size() == 0) { getActivity().finish();//from w w w . ja v a2 s . co m getActivity().startActivity(getActivity().getIntent()); } checkbox = new CheckBox[syncValuesList.size()]; rdoGroups = new RadioGroup[syncValuesList.size()]; TextView[] txvTitles = new TextView[syncValuesList.size()]; int i = 0; int id = 1; Typeface tf_light = Typeface.create("sans-serif-light", 0); Typeface tf_bold = Typeface.create("sans-serif-condensed", 0); for (SyncValue value : syncValuesList) { if (!value.getIsGroup()) { if (value.getType() == SyncValue.Type.CHECKBOX) { checkbox[i] = new CheckBox(scope.context()); checkbox[i].setId(id); checkbox[i].setText(value.getTitle()); checkbox[i].setTypeface(tf_light); layout.addView(checkbox[i]); } else { rdoGroups[i] = new RadioGroup(scope.context()); rdoGroups[i].setId(i + 50); RadioButton[] rdoButtons = new RadioButton[value.getRadioGroups().size()]; int mId = 1; int j = 0; for (SyncValue rdoVal : value.getRadioGroups()) { rdoButtons[j] = new RadioButton(scope.context()); rdoButtons[j].setId(mId); rdoButtons[j].setText(rdoVal.getTitle()); rdoButtons[j].setTypeface(tf_light); rdoGroups[i].addView(rdoButtons[j]); mId++; j++; } layout.addView(rdoGroups[i]); } authorities.put(id + "", value.getAuthority()); i++; id++; } else { txvTitles[i] = new TextView(scope.context()); txvTitles[i].setId(id); txvTitles[i].setText(value.getTitle()); txvTitles[i].setAllCaps(true); txvTitles[i].setPadding(0, 5, 0, 3); txvTitles[i].setTypeface(tf_bold); layout.addView(txvTitles[i]); View lineView = new View(scope.context()); lineView.setBackgroundColor(Color.parseColor("#BEBEBE")); lineView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1)); layout.addView(lineView); } } }