Java Code Examples for android.widget.CheckBox#setText()
The following examples show how to use
android.widget.CheckBox#setText() .
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: CheckBoxModel.java From SmileEssence with MIT License | 6 votes |
@Override public View getView(Activity activity, LayoutInflater inflater, View convertedView) { if (convertedView == null) { convertedView = inflater.inflate(R.layout.menu_item_checkbox, null); } CheckBox checkBox = (CheckBox) convertedView.findViewById(R.id.checkBox_menuItem); checkBox.setText(this.text); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { CheckBoxModel.this.checked = isChecked; } }); checkBox.setChecked(checked); return convertedView; }
Example 2
Source File: CredentialsAskTask.java From xpra-client with GNU General Public License v3.0 | 6 votes |
private void buildPrompts(LinearLayout layout) { final LayoutInflater inflater = LayoutInflater.from(context); for (int i = 0; i < prompt.length; ++i) { final View credentialsView = inflater.inflate(R.layout.credentials_item, layout); final TextView promptView = (TextView) credentialsView.findViewById(R.id.promptTextView); final EditText editView = (EditText) credentialsView.findViewById(R.id.passwdEditText); promptView.setText(prompt[i]); credentialsView.setTag(prompt[i]); if (echo[i]) { editView.setInputType(InputType.TYPE_CLASS_TEXT); } else { editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } } final CheckBox checkbox = new CheckBox(context); checkbox.setText("Show password"); checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showPasswords(checkbox.isChecked()); } }); layout.addView(checkbox); }
Example 3
Source File: SimpleCheckDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
@Override public View onCreateContentView(Bundle savedInstanceState) { // inflate and set your custom view here View view = inflate(R.layout.simpledialogfragment_check_box); mCheckBox = (CheckBox) view.findViewById(R.id.checkBox); mCheckBox.setText(getArgString(CHECKBOX_LABEL)); if (savedInstanceState != null){ mCheckBox.setChecked(savedInstanceState.getBoolean(CHECKED, false)); } else { mCheckBox.setChecked(getArguments().getBoolean(CHECKED, false)); } mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { setPositiveButtonEnabled(canGoAhead()); } }); return view; }
Example 4
Source File: CustomProgressDialog.java From commcare-android with Apache License 2.0 | 6 votes |
private void setupDeterminateView(View view) { ProgressBar bar = view.findViewById(R.id.progress_bar_horizontal); bar.setProgress(progressBarProgress); bar.setMax(progressBarMax); if (progressBarIsVisible) { bar.setVisibility(View.VISIBLE); } else { bar.setVisibility(View.GONE); } if (usingCheckbox) { CheckBox cb = view.findViewById(R.id.progress_dialog_checkbox); cb.setVisibility(View.VISIBLE); cb.setText(checkboxText); cb.setOnClickListener(v -> isChecked = ((CheckBox)v).isChecked()); if (isChecked) { cb.toggle(); } } }
Example 5
Source File: CustomControlsFragment.java From SmartPack-Kernel-Manager with GNU General Public License v3.0 | 6 votes |
private void warningDialog() { View checkBoxView = View.inflate(getActivity(), R.layout.rv_checkbox, null); CheckBox checkBox = checkBoxView.findViewById(R.id.checkbox); checkBox.setChecked(true); checkBox.setText(getString(R.string.always_show)); checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> mAlertDialogue = isChecked); new Dialog(Objects.requireNonNull(getActivity())) .setIcon(R.mipmap.ic_launcher) .setTitle(getString(R.string.warning)) .setMessage(getString(R.string.custom_controls_message)) .setCancelable(false) .setView(checkBoxView) .setNeutralButton(getString(R.string.documentation), (dialog, id) -> Utils.launchUrl("https://smartpack.github.io/spkm/customcontrols/", getActivity())) .setPositiveButton(getString(R.string.got_it), (dialog, id) -> Prefs.saveBoolean("custom_control_warning", mAlertDialogue, getActivity())) .show(); }
Example 6
Source File: Dialog.java From PocketMaps with MIT License | 6 votes |
public static void showAutoSelectMapSelector(Activity activity) { AlertDialog.Builder builder1 = new AlertDialog.Builder(activity); builder1.setTitle(R.string.autoselect_map); builder1.setCancelable(true); final CheckBox cb = new CheckBox(activity.getBaseContext()); cb.setChecked(Variable.getVariable().getAutoSelectMap()); cb.setText(R.string.autoselect_map_text); builder1.setView(cb); OnClickListener listener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int buttonNr) { Variable.getVariable().setAutoSelectMap(cb.isChecked()); Variable.getVariable().saveVariables(Variable.VarType.Base); } }; builder1.setPositiveButton(R.string.ok, listener); AlertDialog alert11 = builder1.create(); alert11.show(); }
Example 7
Source File: SimpleCheckDialog.java From SimpleDialogFragments with Apache License 2.0 | 6 votes |
@Override public View onCreateContentView(Bundle savedInstanceState) { // inflate and set your custom view here View view = inflate(R.layout.simpledialogfragment_check_box); mCheckBox = (CheckBox) view.findViewById(R.id.checkBox); mCheckBox.setText(getArgString(CHECKBOX_LABEL)); if (savedInstanceState != null){ mCheckBox.setChecked(savedInstanceState.getBoolean(CHECKED, false)); } else { mCheckBox.setChecked(getArguments().getBoolean(CHECKED, false)); } mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { setPositiveButtonEnabled(canGoAhead()); } }); return view; }
Example 8
Source File: EmailAutoCompleteLayout.java From EmailAutoCompleteTextView with Apache License 2.0 | 6 votes |
public EmailAutoCompleteLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10 super(context, attrs); backgroundPermissionManager = new BackgroundPermissionManager(this, context); setOrientation(LinearLayout.VERTICAL); setAddStatesFromChildren(true); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EmailAutoCompleteLayout, defStyleAttr, defStyleRes); CharSequence permissionText = a.getText(R.styleable.EmailAutoCompleteLayout_permissionText); if (permissionText == null) { permissionText = context.getString(R.string.message_get_accounts_permission); } a.recycle(); permissionPrimer = new CheckBox(context); permissionPrimer.setTextColor(0x8a000000); permissionPrimer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); permissionPrimer.setText(permissionText); addView(permissionPrimer); }
Example 9
Source File: SignInFragment.java From line-sdk-android with Apache License 2.0 | 5 votes |
private void buildScopeCheckBoxes() { final List<Scope> scopes = (BuildConfig.INCLUDE_INTERNAL_API_TEST) ? Arrays.asList( Scope.PROFILE, Scope.OPENID_CONNECT, Scope.OC_EMAIL, Scope.OC_PHONE_NUMBER, Scope.OC_GENDER, Scope.OC_BIRTHDATE, Scope.OC_ADDRESS, Scope.OC_REAL_NAME, Scope.FRIEND, Scope.GROUP, Scope.MESSAGE, Scope.ONE_TIME_SHARE, Scope.OPEN_CHAT_TERM_STATUS, Scope.OPEN_CHAT_ROOM_CREATE_JOIN, Scope.OPEN_CHAT_SUBSCRIPTION_INFO ) : Arrays.asList( Scope.PROFILE, Scope.OPENID_CONNECT, new Scope("self_defined_scope") ); final FragmentActivity activity = getActivity(); for (final Scope scope : scopes) { final CheckBox checkBox = new CheckBox(activity); checkBox.setText(scope.getCode()); checkBox.setTag(scope); scopeCheckboxLayout.addView(checkBox); scopeCheckBoxes.add(checkBox); } }
Example 10
Source File: RefreshAndMoreActivity2.java From YCRefreshView with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem item = menu.findItem(R.id.checkbox); CheckBox box = (CheckBox) item.getActionView(); box.setChecked(true); box.setText("网络"); box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { hasNetWork = isChecked; } }); return true; }
Example 11
Source File: UserSelectActivity.java From hayoou-wechat-export with GNU General Public License v3.0 | 5 votes |
protected void loadUserList() { LinearLayout userListContainer = (LinearLayout)findViewById(R.id.user_list_container); //ArrayList<UserSnsInfo> userSnsList = Share.snsData.userSnsList; checkBoxList.clear(); userListContainer.removeAllViews(); //userSnsList.get(i).snsList.size(); ArrayList<UserSnsInfo> snsSizeRank = Share.snsData.userSnsList;//new ArrayList<UserSnsInfo>(userSnsList); Collections.sort(snsSizeRank, new Comparator<UserSnsInfo>() { @Override public int compare(UserSnsInfo lhs, UserSnsInfo rhs) { if (rhs.snsList.size() - lhs.snsList.size() > 0) { return 1; } else if (rhs.snsList.size() - lhs.snsList.size() < 0) { return -1; } else { return 0; } } }); UserSnsInfo userSnsInfo2=null; for (int i=0;i<snsSizeRank.size();i++) { userSnsInfo2 = snsSizeRank.get(i); CheckBox userCheckBox = new CheckBox(this); userCheckBox.setText(userSnsInfo2.authorName + "(" + userSnsInfo2.userId + ")" + "(" + String.format(getString(R.string.user_moment_count), userSnsInfo2.snsList.size()) + ")"); userListContainer.addView(userCheckBox); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)userCheckBox.getLayoutParams(); layoutParams.setMargins(5, 5, 5, 5); userCheckBox.setLayoutParams(layoutParams); userCheckBox.setChecked(true); userCheckBox.setTag(userSnsInfo2.userId); checkBoxList.add(userCheckBox); } }
Example 12
Source File: SixStickyNormalActivity.java From YCRefreshView with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem item = menu.findItem(R.id.checkbox); CheckBox box = (CheckBox) item.getActionView(); box.setChecked(true); box.setText("网络"); box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { hasNetWork = isChecked; } }); return true; }
Example 13
Source File: CheckBoxDialogBuilder.java From EhViewer with Apache License 2.0 | 5 votes |
@SuppressLint("InflateParams") public CheckBoxDialogBuilder(Context context, String message, String checkText, boolean checked) { super(context); View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_checkbox_builder, null); setView(view); TextView messageView = (TextView) view.findViewById(R.id.message); mCheckBox = (CheckBox) view.findViewById(R.id.checkbox); messageView.setText(message); mCheckBox.setText(checkText); mCheckBox.setChecked(checked); }
Example 14
Source File: RefreshAndMoreActivity1.java From YCRefreshView with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem item = menu.findItem(R.id.checkbox); CheckBox box = (CheckBox) item.getActionView(); box.setChecked(true); box.setText("网络"); box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { hasNetWork = isChecked; } }); return true; }
Example 15
Source File: TestCaseAdapter.java From azure-notificationhubs-android with Apache License 2.0 | 5 votes |
/** * Returns the view for a specific item on the list */ @Override public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; final TestCase testCase = getItem(position); if (row == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); row = inflater.inflate(mLayoutResourceId, parent, false); } final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkTestCase); String text = String.format("%s - %s", testCase.getName(), testCase.getStatus().toString()); if (testCase.getStatus() == TestStatus.Failed) { checkBox.setTextColor(Color.RED); } else if (testCase.getStatus() == TestStatus.Passed) { checkBox.setTextColor(Color.GREEN); } else { checkBox.setTextColor(Color.BLACK); } checkBox.setText(text); checkBox.setChecked(testCase.isEnabled()); checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { testCase.setEnabled(checkBox.isChecked()); } }); return row; }
Example 16
Source File: OBooleanField.java From framework with GNU Affero General Public License v3.0 | 4 votes |
public void initControl() { mReady = false; LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); removeAllViews(); setOrientation(VERTICAL); if (isEditable()) { if (mWidget != null) { switch (mWidget) { case Switch: mSwitch = new Switch(mContext); mSwitch.setLayoutParams(params); mSwitch.setOnCheckedChangeListener(this); setValue(getValue()); if (mLabel != null) mSwitch.setText(mLabel); if (textSize > -1) { mSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { mSwitch.setTextAppearance(mContext, appearance); } mSwitch.setTextColor(textColor); addView(mSwitch); break; default: break; } } else { mCheckbox = new CheckBox(mContext); mCheckbox.setLayoutParams(params); mCheckbox.setOnCheckedChangeListener(this); if (mLabel != null) mCheckbox.setText(mLabel); if (textSize > -1) { mCheckbox.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { mCheckbox.setTextAppearance(mContext, appearance); } mCheckbox.setTextColor(textColor); addView(mCheckbox); } } else { txvView = new TextView(mContext); txvView.setLayoutParams(params); txvView.setText(getCheckBoxLabel()); if (mLabel != null) txvView.setText(mLabel); if (textSize > -1) { txvView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { txvView.setTextAppearance(mContext, appearance); } addView(txvView); } }
Example 17
Source File: AddVoiceSettingActivity.java From your-local-weather with GNU General Public License v3.0 | 4 votes |
private void populateDayOfWeeks() { Long daysOfWeek = voiceSettingParametersDbHelper.getLongParam( voiceSettingId, VoiceSettingParamType.VOICE_SETTING_TRIGGER_DAY_IN_WEEK.getVoiceSettingParamTypeId()); if (daysOfWeek == null) { return; } Calendar calendar = Calendar.getInstance(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE", applicationLocale); CheckBox triggerCheckBox = findViewById(R.id.voice_trigger_mon); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); triggerCheckBox.setText(simpleDateFormat.format(calendar.getTime())); if (TimeUtils.isCurrentSettingIndex(daysOfWeek, 6)) { triggerCheckBox.setChecked(true); } calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); triggerCheckBox = findViewById(R.id.voice_trigger_tue); triggerCheckBox.setText(simpleDateFormat.format(calendar.getTime())); if (TimeUtils.isCurrentSettingIndex(daysOfWeek, 5)) { triggerCheckBox.setChecked(true); } calendar.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); triggerCheckBox = findViewById(R.id.voice_trigger_wed); triggerCheckBox.setText(simpleDateFormat.format(calendar.getTime())); if (TimeUtils.isCurrentSettingIndex(daysOfWeek, 4)) { triggerCheckBox.setChecked(true); } calendar.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); triggerCheckBox = findViewById(R.id.voice_trigger_thu); triggerCheckBox.setText(simpleDateFormat.format(calendar.getTime())); if (TimeUtils.isCurrentSettingIndex(daysOfWeek, 3)) { triggerCheckBox.setChecked(true); } calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); triggerCheckBox = findViewById(R.id.voice_trigger_fri); triggerCheckBox.setText(simpleDateFormat.format(calendar.getTime())); if (TimeUtils.isCurrentSettingIndex(daysOfWeek, 2)) { triggerCheckBox.setChecked(true); } calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); triggerCheckBox = findViewById(R.id.voice_trigger_sat); triggerCheckBox.setText(simpleDateFormat.format(calendar.getTime())); if (TimeUtils.isCurrentSettingIndex(daysOfWeek, 1)) { triggerCheckBox.setChecked(true); } calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); triggerCheckBox = findViewById(R.id.voice_trigger_sun); triggerCheckBox.setText(simpleDateFormat.format(calendar.getTime())); if (TimeUtils.isCurrentSettingIndex(daysOfWeek, 0)) { triggerCheckBox.setChecked(true); } }
Example 18
Source File: FavoriteDialogs.java From MCPDict with MIT License | 4 votes |
public static void delete(final char unicode, boolean force) { if (force) { UserDatabase.deleteFavorite(unicode); String message = String.format(activity.getString(R.string.favorite_delete_done), unicode); Boast.showText(activity, message, Toast.LENGTH_SHORT); FavoriteFragment fragment = activity.getFavoriteFragment(); if (fragment != null) { FavoriteCursorAdapter adapter = (FavoriteCursorAdapter) fragment.getListAdapter(); adapter.collapseItem(unicode); } activity.getCurrentFragment().refresh(); return; } final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity); final String prefKey = activity.getString(R.string.pref_key_favorite_delete_no_confirm_expiry); long expiry = sp.getLong(prefKey, 0); long now = System.currentTimeMillis(); boolean expired = (expiry == 0 || now > expiry); if (!expired) { delete(unicode, true); return; } final CheckBox checkBox = new CheckBox(activity); checkBox.setText(R.string.favorite_delete_no_confirm); new AlertDialog.Builder(activity) .setIcon(R.drawable.ic_alert) .setTitle(String.format(activity.getString(R.string.favorite_delete), unicode)) .setMessage(String.format(activity.getString(R.string.favorite_delete_confirm), unicode)) .setView(checkBox) .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { delete(unicode, true); if (checkBox.isChecked()) { sp.edit().putLong(prefKey, System.currentTimeMillis() + 3600000).commit(); // No confirmation for 1 hour } } }) .setNegativeButton(R.string.cancel, null) .show(); }
Example 19
Source File: BlurBenchmarkFragment.java From BlurTestAndroid with Apache License 2.0 | 4 votes |
private CheckBox createAlgorithmCheckbox(EBlurAlgorithm algorithm, LayoutInflater inflater) { CheckBox cb = (CheckBox) inflater.inflate(R.layout.inc_algorithm_checkbox, null); cb.setText(algorithm.toString()); cb.setTag(algorithm); return cb; }
Example 20
Source File: MainActivity.java From Emoji with Apache License 2.0 | 4 votes |
@Override @SuppressLint("SetTextI18n") protected void onCreate(final Bundle savedInstanceState) { getLayoutInflater().setFactory2(new MaterialEmojiLayoutFactory((LayoutInflater.Factory2) getDelegate())); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); chatAdapter = new ChatAdapter(); final Button button = findViewById(R.id.main_activity_material_button); button.setText("\uD83D\uDE18\uD83D\uDE02\uD83E\uDD8C"); editText = findViewById(R.id.main_activity_chat_bottom_message_edittext); rootView = findViewById(R.id.main_activity_root_view); emojiButton = findViewById(R.id.main_activity_emoji); final ImageView sendButton = findViewById(R.id.main_activity_send); emojiButton.setColorFilter(ContextCompat.getColor(this, R.color.emoji_icons), PorterDuff.Mode.SRC_IN); sendButton.setColorFilter(ContextCompat.getColor(this, R.color.emoji_icons), PorterDuff.Mode.SRC_IN); final CheckBox forceEmojisOnly = findViewById(R.id.main_activity_force_emojis_only); forceEmojisOnly.setText("Force emojis only \uD83D\uDE18"); forceEmojisOnly.setOnCheckedChangeListener((ignore, isChecked) -> { if (isChecked) { editText.clearFocus(); emojiButton.setVisibility(GONE); editText.disableKeyboardInput(emojiPopup); } else { emojiButton.setVisibility(VISIBLE); editText.enableKeyboardInput(); } }); emojiButton.setOnClickListener(ignore -> emojiPopup.toggle()); sendButton.setOnClickListener(ignore -> { final String text = editText.getText().toString().trim(); if (text.length() > 0) { chatAdapter.add(text); editText.setText(""); } }); final RecyclerView recyclerView = findViewById(R.id.main_activity_recycler_view); recyclerView.setAdapter(chatAdapter); recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); setUpEmojiPopup(); }