本文整理汇总了Java中android.widget.CheckBox.setOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBox.setOnClickListener方法的具体用法?Java CheckBox.setOnClickListener怎么用?Java CheckBox.setOnClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.CheckBox
的用法示例。
在下文中一共展示了CheckBox.setOnClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initView
import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public void initView() {
back = (ImageView) findViewById(R.id.iv_picture_top_bar_back);
description = (TextView) findViewById(R.id.tv_picture_top_bar_description);
finish = (Button) findViewById(R.id.btn_picture_top_bar_finish);
delete = (ImageView) findViewById(R.id.iv_picture_top_bar_delete);
topBar = (RelativeLayout) findViewById(R.id.picture_top_bar);
bottomView = (RelativeLayout) findViewById(R.id.rl_base_preview_bottom);
origin = (CheckBox) findViewById(R.id.cb_base_preview_origin);
select = (CheckBox) findViewById(R.id.cb_base_preview_select);
display = (PreviewViewPager) findViewById(R.id.vp_base_preview_display);
back.setOnClickListener(this);
delete.setOnClickListener(this);
select.setOnClickListener(this);
finish.setOnClickListener(this);
origin.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
origin.setText(getString(R.string.origin_size, previewList.get(currentPosition).getSize()));
} else {
origin.setText(getString(R.string.origin_text));
}
}
});
}
示例2: getView
import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(layout, viewGroup, false);
}
final TextView name = (TextView) view.findViewById(R.id.name);
name.setText(friends.get(i).name);
final TextView location = (TextView) view.findViewById(R.id.location);
location.setText(getAddress(friends.get(i).locationy,friends.get(i).locationx));
final CheckBox box = (CheckBox) view.findViewById(R.id.checkBox);
box.setOnClickListener(new CheckBoxOnClickListener(i,friends));
return view;
}
示例3: initView
import android.widget.CheckBox; //导入方法依赖的package包/类
private void initView() {
btnBack= (Button) findViewById(R.id.btn_back);
ckAll= (CheckBox) findViewById(R.id.ck_all);
tvShowPrice= (TextView) findViewById(R.id.tv_show_price);
tvSettlement= (TextView) findViewById(R.id.tv_settlement);
btnEdit= (TextView) findViewById(R.id.bt_header_right);
list_shopping_cart= (ListView) findViewById(R.id.list_shopping_cart);
btnEdit.setOnClickListener(this);
ckAll.setOnClickListener(this);
tvSettlement.setOnClickListener(this);
btnBack.setOnClickListener(this);
initData();
}
示例4: ActivityHolder
import android.widget.CheckBox; //导入方法依赖的package包/类
public ActivityHolder(View itemView) {
super(itemView);
mAppNameTB = (TextView) itemView.findViewById(R.id.appNameTextBox);
mAppSelectCB = (CheckBox) itemView.findViewById(R.id.appSelectCheckBox);
mImageView = (ImageView) itemView.findViewById(R.id.appIconImageView);
mSettingsIB = (ImageButton) itemView.findViewById(R.id.appSettingsIcon);
mAppSelectCB.setOnClickListener(this);
mSettingsIB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), AppSettingsActivity.class);
AppSelection appSelection = getAppSelection(mAppSelection.getAppPackageName());
if (appSelection == null) { // Never going to happen but let's cover our bases
appSelection = mAppSelection;
}
intent.putExtra(AppSettingsActivity.APP_SELECTION_EXTRA, appSelection);
startActivityForResult(intent, APP_SELECTIONS_REQUEST, LAUNCH_ACTIVITY_ANIM_BUNDLE);
}
});
}
示例5: onActivityCreated
import android.widget.CheckBox; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
tos = (TextView) getView().findViewById(R.id.tostext);
tos.setText(Html.fromHtml(getActivity().getResources().getString(R.string.tos)));
read = (CheckBox) getView().findViewById(R.id.checkBox);
read.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checked = read.isChecked();
}
});
}
示例6: setCheckBox
import android.widget.CheckBox; //导入方法依赖的package包/类
/**
* 全选或者全不选
*/
private void setCheckBox(final CheckBox checkBox) {
checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkAll_None(checkBox.isChecked()); //需要判断是全选或全不选
showTotalPrice();
}
});
}
示例7: initViews
import android.widget.CheckBox; //导入方法依赖的package包/类
public void initViews() {
random = (ImageView) activity.findViewById(R.id.sheet_detail_songs_icon);
playAllRandom = (TextView) activity.findViewById(R.id.sheet_detail_songs_play_random);
line = activity.findViewById(R.id.sheet_detail_songs_line);
songList = (RecyclerView) activity.findViewById(R.id.sheet_detail_songs_list);
randomContainer = activity.findViewById(R.id.sheet_detail_random_container);
checkContainer = activity.findViewById(R.id.sheet_detail_check_container);
checkAll = (CheckBox) activity.findViewById(R.id.sheet_detail_check_all);
checkCount = (TextView) activity.findViewById(R.id.sheet_detail_check_count);
checkAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isChecked = checkAll.isChecked();
if (isChecked) {
songAdapter.checkAll();
} else {
songAdapter.clearAllCheck();
}
}
});
randomContainer.setOnClickListener(this);
FloatingActionButton fabPlayAll = (FloatingActionButton) activity.findViewById(R.id.sheet_detail_play_all);
fabPlayAll.setOnClickListener(this);
songList.post(new Runnable() {
@Override
public void run() {
calculateRecycleViewHeight();
}
});
}
示例8: onCreate
import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContainer = (RelativeLayout) findViewById(R.id.rl_container);
mEditTextTitle = (EditText) findViewById(R.id.edit_text_title);
mEditTextContent = (EditText) findViewById(R.id.edit_text_content);
mButtonClear = (TextView) findViewById(R.id.text_clear);
mButtonOK = (TextView) findViewById(R.id.text_ok);
mCheckBoxSelfStarting = (CheckBox) findViewById(R.id.check_box_self_starting);
mContainer.setOnClickListener(this);
mButtonOK.setOnClickListener(this);
mButtonClear.setOnClickListener(this);
mCheckBoxSelfStarting.setOnClickListener(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mEditTextContent.setSingleLine(false);
mEditTextContent.setMaxLines(5);
}
mContext = getApplicationContext();
mSharedPreferences = getSharedPreferences(KEY_SETTING, MODE_PRIVATE);
mEditTextTitle.setText(mSharedPreferences.getString(KEY_TITLE, ""));
mEditTextContent.setText(mSharedPreferences.getString(KEY_CONTENT, ""));
mCheckBoxSelfStarting.setChecked(mSharedPreferences.getBoolean(KEY_SELF_STARTING, false));
Intent intent = getIntent();
String action = intent.getAction();
Bundle extras = intent.getExtras();
if (Intent.ACTION_SEND.equals(action)) {
if (extras.containsKey(Intent.EXTRA_TEXT)) {
mEditTextContent.getText().append("\n").append(extras.getString(Intent.EXTRA_TEXT));
}
}
}
示例9: DataViewHolder
import android.widget.CheckBox; //导入方法依赖的package包/类
DataViewHolder(View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(tv);
imageView = (ImageView) itemView.findViewById(R.id.iv);
checkBox = (CheckBox) itemView.findViewById(R.id.cb);
if (checkBoxEnabled) {
checkBox.setVisibility(View.VISIBLE);
checkBox.setOnClickListener(this);
}
else
{
checkBox.setVisibility(View.GONE);
}
}
示例10: initView
import android.widget.CheckBox; //导入方法依赖的package包/类
private void initView() {
removeAllViews();
for (int i = 0; i < countNum; i++) {
CheckBox cb = new CheckBox(getContext());
LayoutParams layoutParams;
if (widthAndHeight == 0) {
layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
} else {
layoutParams = new LayoutParams((int) widthAndHeight, (int) widthAndHeight);
}
if (differentSize && countNum % 2 != 0) {
Log.e("xxx", layoutParams.width + "");
int index = i;
if (index > countNum / 2) {
index = countNum - 1 - index;
}
float scale = (index + 1) / (float) (countNum / 2 + 1);
layoutParams.width = (int) (layoutParams.width * scale);
layoutParams.height = layoutParams.width;
}
layoutParams.gravity = Gravity.CENTER_VERTICAL;
if (i != 0 && i != countNum - 1) {
layoutParams.leftMargin = (int) dividerWidth;
layoutParams.rightMargin = (int) dividerWidth;
} else if (i == 0) {
layoutParams.rightMargin = (int) dividerWidth;
} else if (i == countNum - 1) {
layoutParams.leftMargin = (int) dividerWidth;
}
addView(cb, layoutParams);
cb.setButtonDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
if (stateResId == -1) {
stateResId = R.drawable.book_review_rating_bar_selector;
}
cb.setBackgroundResource(stateResId);
if (i + 1 <= countSelected) {
cb.setChecked(true);
}
cb.setEnabled(canEdit);
cb.setOnClickListener(new MyClickListener(i));
}
}
示例11: onCreate
import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_list);
TitleBar _titleBar = (TitleBar) findViewById(R.id.titleBar);
_text_path = (EditText) findViewById(R.id.edittext_path);
RecyclerView _list = (RecyclerView) findViewById(R.id.recyclerview);
_buttonbar = (LinearLayout) findViewById(R.id.linearlayout_buttonbar);
View _button_delete = findViewById(R.id.textView_delete);
View _button_clean = findViewById(R.id.textView_clean);
View _button_hold = findViewById(R.id.textView_hold);
View _button_close = findViewById(R.id.imageview_close);
_checkbox_all = (CheckBox) findViewById(R.id.checkbox_all);
if (Global.get_rootFile() == null) {
FileManager.reset();
finish();
return;
}
_titleBar.setTitle(R.string.caption_text_mine);
_basic_path = Global.get_rootFile().get_path();
_text_path.setText(Global.get_rootFile().get_path().replace(_basic_path, getString(R.string.str_path_rootFile)));
_layoutManager = new LinearLayoutManager(this);
_layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
_list.setLayoutManager(_layoutManager);
_adapter = new FileListAdapter(this, this);
_adapter.set_data(Global.get_rootFile());
_list.setAdapter(_adapter);
_list.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
_broadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
_button_delete.setTag(new String[]{ACTION_DELETE});
_button_clean.setTag(new String[]{ACTION_CLEAN});
_button_hold.setTag(new String[]{ACTION_HOLD});
_checkbox_all.setTag(new String[]{ACTION_CHECK});
_button_close.setTag(new String[]{ACTION_CLOSE});
_button_delete.setOnClickListener(this);
_button_clean.setOnClickListener(this);
_button_hold.setOnClickListener(this);
_checkbox_all.setOnClickListener(this);
_button_close.setOnClickListener(this);
}
示例12: addItemPrefWithToggle
import android.widget.CheckBox; //导入方法依赖的package包/类
public ItemBuilder addItemPrefWithToggle(Context context, String title, String subtitle, boolean isChecked, boolean useSwitch, boolean isProFeature, boolean userIsPro, String preferenceCONST, String settingsEnabledAction, String settingsDisabledAction) {
view = inflater.inflate(R.layout.item_element_title_subtitle_checkbox, parent, false);
TextView tv = (TextView) view.findViewById(R.id.tv_title);
tv.setText(title);
TextView tv2 = (TextView) view.findViewById(R.id.tv_subtitle);
tv2.setText(subtitle);
CheckBox checkboxButton = (CheckBox) view.findViewById(R.id.cb_pref);
SwitchCompat switchButton = (SwitchCompat) view.findViewById(R.id.sw_pref);
checkboxButton.setChecked(isChecked);
switchButton.setChecked(isChecked);
if (useSwitch) {
apply(checkboxButton, GONE);
apply(switchButton, VISIBLE);
} else {
apply(checkboxButton, VISIBLE);
apply(switchButton, GONE);
}
View.OnClickListener listener = view1 -> {
if (SettingsPreferences.isGenericSettingEnabled(context, preferenceCONST, true)) {
SettingsPreferences.disableGenericSetting(context, preferenceCONST);
AnalyticsHelper.getInstance(context).logScreenEvent(SCREEN_SETTINGS, settingsDisabledAction);
checkboxButton.setChecked(false);
switchButton.setChecked(false);
} else {
SettingsPreferences.enableGenericSetting(context, preferenceCONST);
AnalyticsHelper.getInstance(context).logScreenEvent(SCREEN_SETTINGS, settingsEnabledAction);
checkboxButton.setChecked(true);
switchButton.setChecked(true);
}
};
if (!isProFeature || userIsPro) {
checkboxButton.setEnabled(true);
switchButton.setEnabled(true);
checkboxButton.setOnClickListener(listener);
switchButton.setOnClickListener(listener);
view.setOnClickListener(listener);
} else {
checkboxButton.setChecked(true);
switchButton.setChecked(true);
checkboxButton.setEnabled(false);
switchButton.setEnabled(false);
}
return this;
}
示例13: openingHoursLayoutSetup
import android.widget.CheckBox; //导入方法依赖的package包/类
private void openingHoursLayoutSetup() {
hoursSwitch24_7 = (Switch) getActivity().findViewById(R.id.hoursSwitch24_7);
hoursSwitch24_7.setChecked(false);
extendedOpeningHoursContainer = (LinearLayout) getActivity().findViewById(R.id.extendedOpeningHoursContainer);
extendedOpeningHoursContainer.setVisibility(View.VISIBLE);
openingHours = (TextView) getActivity().findViewById(R.id.openingHours);
closingHours = (TextView) getActivity().findViewById(R.id.closingHours);
//week CheckBoxes
checkboxMonday = (CheckBox) getActivity().findViewById(R.id.checkboxMonday);
checkboxTuesday = (CheckBox) getActivity().findViewById(R.id.checkboxTuesday);
checkboxWednesday = (CheckBox) getActivity().findViewById(R.id.checkboxWednesday);
checkboxThursday = (CheckBox) getActivity().findViewById(R.id.checkboxThursday);
checkboxFriday = (CheckBox) getActivity().findViewById(R.id.checkboxFriday);
checkboxSaturday = (CheckBox) getActivity().findViewById(R.id.checkboxSaturday);
checkboxSunday = (CheckBox) getActivity().findViewById(R.id.checkboxSunday);
checkboxAll = (CheckBox) getActivity().findViewById(R.id.checkboxAll);
checkboxMonday.setOnClickListener(openingHoursViewListener);
checkboxTuesday.setOnClickListener(openingHoursViewListener);
checkboxWednesday.setOnClickListener(openingHoursViewListener);
checkboxThursday.setOnClickListener(openingHoursViewListener);
checkboxFriday.setOnClickListener(openingHoursViewListener);
checkboxSaturday.setOnClickListener(openingHoursViewListener);
checkboxSunday.setOnClickListener(openingHoursViewListener);
checkboxAll.setOnClickListener(openingHoursViewListener);
hoursSwitch24_7.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked) {
//do stuff when Switch is ON
extendedOpeningHoursContainer.setVisibility(View.GONE);
} else {
//do stuff when Switch if OFF
extendedOpeningHoursContainer.setVisibility(View.VISIBLE);
}
}
});
openingHours.setOnClickListener(openingHoursViewListener);
closingHours.setOnClickListener(openingHoursViewListener);
}
示例14: openingHoursLayoutSetup
import android.widget.CheckBox; //导入方法依赖的package包/类
private void openingHoursLayoutSetup() {
openingHoursMainContainer = getActivity().findViewById(R.id.openingHoursMainContainer);
hoursSwitch24_7 = (Switch) getActivity().findViewById(R.id.hoursSwitch24_7);
hoursSwitch24_7.setChecked(false);
extendedOpeningHoursContainer = (LinearLayout) getActivity().findViewById(R.id.extendedOpeningHoursContainer);
extendedOpeningHoursContainer.setVisibility(View.VISIBLE);
openingHours = (TextView) getActivity().findViewById(R.id.openingHours);
closingHours = (TextView) getActivity().findViewById(R.id.closingHours);
//week CheckBoxes
checkboxMonday = (CheckBox) getActivity().findViewById(R.id.checkboxMonday);
checkboxTuesday = (CheckBox) getActivity().findViewById(R.id.checkboxTuesday);
checkboxWednesday = (CheckBox) getActivity().findViewById(R.id.checkboxWednesday);
checkboxThursday = (CheckBox) getActivity().findViewById(R.id.checkboxThursday);
checkboxFriday = (CheckBox) getActivity().findViewById(R.id.checkboxFriday);
checkboxSaturday = (CheckBox) getActivity().findViewById(R.id.checkboxSaturday);
checkboxSunday = (CheckBox) getActivity().findViewById(R.id.checkboxSunday);
checkboxAll = (CheckBox) getActivity().findViewById(R.id.checkboxAll);
checkboxMonday.setOnClickListener(openingHoursViewListener);
checkboxTuesday.setOnClickListener(openingHoursViewListener);
checkboxWednesday.setOnClickListener(openingHoursViewListener);
checkboxThursday.setOnClickListener(openingHoursViewListener);
checkboxFriday.setOnClickListener(openingHoursViewListener);
checkboxSaturday.setOnClickListener(openingHoursViewListener);
checkboxSunday.setOnClickListener(openingHoursViewListener);
checkboxAll.setOnClickListener(openingHoursViewListener);
hoursSwitch24_7.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked) {
//do stuff when Switch is ON
extendedOpeningHoursContainer.setVisibility(View.GONE);
} else {
//do stuff when Switch if OFF
extendedOpeningHoursContainer.setVisibility(View.VISIBLE);
}
}
});
openingHours.setOnClickListener(openingHoursViewListener);
closingHours.setOnClickListener(openingHoursViewListener);
}
示例15: onCreate
import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("Dr.com电信版v1.2.0");
btn_login = (Button)findViewById(R.id.btn_login);
btn_logout = (Button)findViewById(R.id.btn_logout);
btn_forgot = (Button)findViewById(R.id.btn_forgot);
btn_save = (Button)findViewById(R.id.btn_save);
cb_auto_exit = (CheckBox)findViewById(R.id.cb_auto_exit);
cb_hide_info = (CheckBox)findViewById(R.id.cb_hide_info);
ed_acc = (EditText)findViewById(R.id.ed_account);
ed_psw = (EditText)findViewById(R.id.ed_psw);
tv_acc = (TextView)findViewById(R.id.tv_acc);
tv_psw = (TextView)findViewById(R.id.tv_psw);
btn_login.setOnClickListener(this);
btn_logout.setOnClickListener(this);
btn_forgot.setOnClickListener(this);
btn_save.setOnClickListener(this);
cb_hide_info.setOnClickListener(this);
cb_auto_exit.setOnClickListener(this);
cb_auto_exit.setChecked(true);
admin = DrcomAdmin.getInstance();
admin.initContext(this);
SharedPreferences sp = getSharedPreferences(PREFERENCES_NAME, Activity.MODE_PRIVATE);
String str_acc = sp.getString("account", "");
String str_psw = sp.getString("password", "");
bool_hideInfo = sp.getBoolean("hideInfo", false);
bool_autoExit = sp.getBoolean("autoExit", true);
if(str_acc != "" && str_psw != ""){
ed_acc.setText(str_acc);
ed_psw.setText(str_psw);
admin.initAccountInfo(str_acc,str_psw);
}
cb_hide_info.setChecked(bool_hideInfo);
cb_auto_exit.setChecked(bool_autoExit);
if(cb_hide_info.isChecked()){
hideInfo();
}
}