当前位置: 首页>>代码示例>>Java>>正文


Java AppCompatCheckBox.setText方法代码示例

本文整理汇总了Java中android.support.v7.widget.AppCompatCheckBox.setText方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatCheckBox.setText方法的具体用法?Java AppCompatCheckBox.setText怎么用?Java AppCompatCheckBox.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.AppCompatCheckBox的用法示例。


在下文中一共展示了AppCompatCheckBox.setText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:20,代码来源:MultiChoiceDialog.java

示例2: ifHuaweiAlert

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
private void ifHuaweiAlert() {
    final SharedPreferences settings = getSharedPreferences("ProtectedApps", MODE_PRIVATE);
    final String saveIfSkip = "skipProtectedAppsMessage";
    boolean skipMessage = settings.getBoolean(saveIfSkip, false);
    if (!skipMessage) {
        final SharedPreferences.Editor editor = settings.edit();
        Intent intent = new Intent();
        intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");
        if (isCallable(intent)) {
            final AppCompatCheckBox dontShowAgain = new AppCompatCheckBox(this);
            dontShowAgain.setText(R.string.Do_not_show_again);
            dontShowAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    editor.putBoolean(saveIfSkip, isChecked);
                    editor.apply();
                }
            });

            new AlertDialog.Builder(this)
                    .setTitle("Huawei Protected Apps")
                    .setMessage(String.format("%s requires to be enabled in 'Protected Apps' to send notifications.%n", getString(R.string.app_name)))
                    .setView(dontShowAgain)
                    .setPositiveButton("Protected Apps", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            huaweiProtectedApps();
                        }
                    })
                    .setNegativeButton("Cancel", null)
                    .show();
        } else {
            editor.putBoolean(saveIfSkip, true);
            editor.apply();
        }
    }
}
 
开发者ID:Cesarsk,项目名称:Say_it,代码行数:37,代码来源:MainActivity.java

示例3: setupCheckbox

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
/**
 * Setups checkbox in menu.
 * @param menu menu
 */
private void setupCheckbox(Menu menu)
{
	AppCompatCheckBox checkBox = (AppCompatCheckBox) menu.findItem(R.id.equalizer_lock).getActionView();
	ColorStateList colorStateList = new ColorStateList(new int[][]{
			new int[]{-android.R.attr.state_enabled}, // disabled
			new int[]{android.R.attr.state_enabled}, // enabled
	},
			new int[]{
					Color.WHITE, // disabled
					Color.WHITE // enabled
			});
	checkBox.setSupportButtonTintList(colorStateList);
	checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
		@Override
		public void onCheckedChanged(CompoundButton compoundButton, boolean b)
		{
			lockedSliders = b;
		}
	});
	checkBox.setText(getString(R.string.lock_sliders));
	checkBox.setChecked(true);
	checkBox.setPadding(0,0,Math.round(getResources().getDimension(R.dimen.activity_horizontal_margin)),0);
}
 
开发者ID:JiriSko,项目名称:amixer-webui-android,代码行数:28,代码来源:EqualizerActivity.java

示例4: CheckBoxMetricWidget

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
public CheckBoxMetricWidget(Context context, MetricValue m) {
    super(context, m);

    final Optional<List<String>> optionalValues = MetricHelper.getListItemIndexRange(m.getMetric());
    if (!optionalValues.isPresent())
        throw new IllegalStateException("Couldn't parse range values, cannot proceed");
    final List<String> rangeValues = optionalValues.get();

    for (int i = 0; i < rangeValues.size(); i++) {
        String value = rangeValues.get(i);
        AppCompatCheckBox checkbox = new AppCompatCheckBox(getContext());
        checkbox.setText(value);
        values.addView(checkbox);
    }

    setMetricValue(m);
}
 
开发者ID:frc2052,项目名称:FRC-Krawler,代码行数:18,代码来源:CheckBoxMetricWidget.java

示例5: setFilters

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
public void setFilters(@Nullable List<SearchFilter> filters) {
    mSearchFilters = filters;
    mFlexboxLayout.removeAllViews();
    if (filters == null) {
        mSearchFiltersStates = null;
        mFlexboxLayout.setVisibility(View.GONE);
    } else {
        mSearchFiltersStates = new ArrayList<>();
        for (SearchFilter filter : filters) {
            AppCompatCheckBox checkBox = new AppCompatCheckBox(mContext);
            checkBox.setText(filter.getTitle());
            checkBox.setTextSize(12);
            checkBox.setTextColor(mTextColor);
            checkBox.setChecked(filter.isChecked());

            FlexboxLayout.LayoutParams lp = new FlexboxLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            lp.setMargins(getResources().getDimensionPixelSize(R.dimen.search_filter_margin_start), getResources().getDimensionPixelSize(R.dimen.search_filter_margin_top), getResources().getDimensionPixelSize(R.dimen.search_filter_margin_top), getResources().getDimensionPixelSize(R.dimen.search_filter_margin_top));

            checkBox.setLayoutParams(lp);
            checkBox.setTag(filter.getTagId());
            mFlexboxLayout.addView(checkBox);
            mSearchFiltersStates.add(filter.isChecked());
        }
    }
}
 
开发者ID:lapism,项目名称:SearchBar-SearchView,代码行数:26,代码来源:SearchView.java

示例6: addMultipleChoice

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
public void addMultipleChoice(String text, boolean checked, final OnCheckListener listener) {
    ColorStateList colorStateList = new ColorStateList(
            new int[][]{
                    new int[]{-android.R.attr.state_enabled}, //disabled
                    new int[]{android.R.attr.state_enabled}, //enabled
                    new int[]{android.R.attr.state_checked}
            },
            new int[]{
                    R.color.checkbox_disabled_color, //disabled
                    R.color.checkbox_enabled_color, //enabled
                    R.color.checkbox_checked_color
            }
    );

    AppCompatCheckBox box = new AppCompatCheckBox(getContext());
    box.setChecked(checked);
    box.setSupportButtonTintList(colorStateList);
    box.setText(localize(text));
    box.setTextColor(getResources().getColor(R.color.text_dark));
    box.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            listener.onCheck(isChecked);
        }
    });
    mCheckBoxes.addView(box);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:28,代码来源:ChoiceView.java

示例7: ifHuaweiAlert

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
private void ifHuaweiAlert() {
    if (Build.MANUFACTURER.equalsIgnoreCase("huawei")) {
        final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getAppContext());

        if (!defaultSharedPreferences.getBoolean("protected_apps", false)) {
            final SharedPreferences.Editor editor = defaultSharedPreferences.edit();

            Intent intent = new Intent();
            intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");

            if (isCallable(intent)) {
                final AppCompatCheckBox dontShowAgain = new AppCompatCheckBox(this);
                dontShowAgain.setText(getString(R.string.protected_apps_skip));
                dontShowAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        editor.putBoolean("protected_apps", isChecked);
                        editor.apply();
                    }
                });

                new AlertDialog.Builder(this)
                        .setTitle(getString(R.string.protected_apps_dialog_title))
                        .setMessage(String.format(getString(R.string.protected_apps_dialog_message), getString(R.string.app_name)))
                        .setView(dontShowAgain)
                        .setPositiveButton(getString(R.string.protected_apps_button), new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                huaweiProtectedApps();
                            }
                        })
                        .setNegativeButton(R.string.close_button, null)
                        .show();
            }
            else {
                editor.putBoolean("protected_apps", true);
                editor.apply();
            }
        }
    }
}
 
开发者ID:tomatrocho,项目名称:insapp-android,代码行数:41,代码来源:MainActivity.java

示例8: ifHuaweiAlert

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
private void ifHuaweiAlert() {
    final SharedPreferences settings = getSharedPreferences("ProtectedApps", MODE_PRIVATE);
    final String saveIfSkip = "skipProtectedAppsMessage";
    boolean skipMessage = settings.getBoolean(saveIfSkip, false);
    if (!skipMessage) {
        final SharedPreferences.Editor editor = settings.edit();
        Intent intent = new Intent();
        intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");
        if (isCallable(intent)) {
            final AppCompatCheckBox dontShowAgain = new AppCompatCheckBox(this);
            dontShowAgain.setText(R.string.text_huawei_dont_show_again);
            dontShowAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    editor.putBoolean(saveIfSkip, isChecked);
                    editor.apply();
                }
            });

            new AlertDialog.Builder(this)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setTitle(getString(R.string.title_huawei_message))
                    .setMessage(getString(R.string.text_huawei_message))
                    .setView(dontShowAgain)
                    .setPositiveButton(getString(R.string.button_huawei_message), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            huaweiProtectedApps();
                        }
                    })
                    .setNegativeButton(android.R.string.cancel, null)
                    .show();
        } else {
            editor.putBoolean(saveIfSkip, true);
            editor.apply();
        }
    }
}
 
开发者ID:coderswithoutborders,项目名称:deglancer,代码行数:38,代码来源:MainActivity.java

示例9: initViewDefault

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
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;
}
 
开发者ID:ResearchStack,项目名称:ResearchStack,代码行数:36,代码来源:MultiChoiceQuestionBody.java

示例10: AlertIfHuaweiDevice

import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
@ReactMethod
public void AlertIfHuaweiDevice(String title, String message, String dontShowAgainText, String positiveText, String negativeText) {
    // read "do not show again" flag
    final SharedPreferences settings = this.getCurrentActivity().getSharedPreferences("ProtectedApps",Context.MODE_PRIVATE);
    final String saveIfSkip = "skipProtectedAppsMessage";
    boolean skipMessage = settings.getBoolean(saveIfSkip, false);
    // Show dialog only when "do not show again" hasn't been enabled yet
    if (!skipMessage) {
        final SharedPreferences.Editor editor = settings.edit();
        Intent intent = new Intent();
        // Check if intent of the Huawei protected apps activity is callable
        intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");
        if (isCallable(intent)) {
            // Prepare dialog
            final AppCompatCheckBox dontShowAgain = new AppCompatCheckBox(this.getCurrentActivity());
            dontShowAgain.setText(dontShowAgainText);
            dontShowAgain.setLeft(20);
            dontShowAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    editor.putBoolean(saveIfSkip, isChecked);
                    editor.apply();
                }
            });

            final RelativeLayout layout = new RelativeLayout(this.getCurrentActivity());
            layout.setPadding(50,50,0,0);
            layout.addView(dontShowAgain);

            new AlertDialog.Builder(this.getCurrentActivity())
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setTitle(title)
                    .setMessage(message)
                    .setView(layout)
                    .setPositiveButton(positiveText, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // Launch huawei Protected Apps Activity
                            huaweiProtectedApps();
                        }
                    })
                    .setNegativeButton(negativeText, null)
                    .show();
        } else {
            // Save "do not show again" flag automatically for non-Huawei devices to prevent unnecessary checks
            editor.putBoolean(saveIfSkip, true);
            editor.apply();
        }
    }
}
 
开发者ID:pgengoux,项目名称:react-native-huawei-protected-apps,代码行数:50,代码来源:HuaweiProtectedAppsModule.java


注:本文中的android.support.v7.widget.AppCompatCheckBox.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。