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


Java CheckBox.setText方法代码示例

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


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

示例1: getCheckStatus

import android.widget.CheckBox; //导入方法依赖的package包/类
private void getCheckStatus(View view, final int position) {
    CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
    checkBox.setText(list.get(position));
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (buttonView.isChecked()) {
                checkStatus.set(position, true);
            }
            else {
                checkStatus.set(position, false);
            }
        }
    });
    checkBox.setChecked(checkStatus.get(position));
}
 
开发者ID:Akari10032,项目名称:12306_Android,代码行数:17,代码来源:Date2Adapter.java

示例2: getChildView

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
    View convertView, ViewGroup parent) {
  if (convertView == null) {
    convertView = inflater.inflate(R.layout.test_loop_item, parent, false);
  }
  CheckBox checkBox = (CheckBox) convertView;
  if (childPosition == 0) {
    boolean allSelected = checkedScenarios.containsAll(getGroup(groupPosition).getLoops());
    checkBox.setChecked(allSelected);
    if (allSelected) {
      checkBox.setText(R.string.unselect_all);
    } else {
      checkBox.setText(R.string.select_all);
    }
  } else {
    Integer item = getChild(groupPosition, childPosition - 1);
    checkBox.setText(String.valueOf(item));
    checkBox.setChecked(checkedScenarios.contains(item));
  }
  return convertView;
}
 
开发者ID:googlesamples,项目名称:testloopmanager,代码行数:23,代码来源:TestLoopGroupAdapter.java

示例3: addItemTrainCategories

import android.widget.CheckBox; //导入方法依赖的package包/类
public ItemBuilder addItemTrainCategories(Context context) {
    view = inflater.inflate(R.layout.item_element_categories_checkboxes, parent, false);
    TextView      tv            = (TextView) view.findViewById(R.id.tv_title);
    TextView      tv2           = (TextView) view.findViewById(R.id.tv_subtitle);
    FlexboxLayout fblCategories = (FlexboxLayout) view.findViewById(R.id.fbl_categories);
    tv.setText("Categorie di treni incluse nella ricerca");
    tv2.setText(SettingsPreferences.getCategoriesAsString(context, " / "));
    for (ENUM_CATEGORIES cat : ENUM_CATEGORIES.values()) {
        CheckBox                   cbCat  = new CheckBox(context);
        FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.flexBasisPercent = 0.5f;
        cbCat.setLayoutParams(params);
        cbCat.setText(cat.getAlias());
        cbCat.setChecked(SettingsPreferences.isCategoryEnabled(context, cat));
        cbCat.setOnCheckedChangeListener((buttonView, isChecked) -> {
            if (isChecked || (!isChecked && SettingsPreferences.isPossibleToDisableCheckbox(context))) {
                SettingsPreferences.setCategory(context, cat.name(), isChecked);
                tv2.setText(SettingsPreferences.getCategoriesAsString(context, " / "));
            } else {
                cbCat.setChecked(true);
            }
        });
        fblCategories.addView(cbCat);
    }
    return this;
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:27,代码来源:ItemBuilder.java

示例4: onCreateContentView

import android.widget.CheckBox; //导入方法依赖的package包/类
@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;
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:25,代码来源:SimpleCheckDialog.java

示例5: addCheckBoxes

import android.widget.CheckBox; //导入方法依赖的package包/类
protected void addCheckBoxes() {
    llContainer = (LinearLayout) findViewById(R.id.ll_container);
    for(String name : NAMES) {
        CheckBox cb = new CheckBox(this);
        cb.setText(name);
        llContainer.addView(cb);
    }
}
 
开发者ID:rome753,项目名称:ActivityTaskView,代码行数:9,代码来源:BaseActivity.java

示例6: onCreate

import android.widget.CheckBox; //导入方法依赖的package包/类
@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
        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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:DirectorySample.java

示例7: init

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void init() {
    super.init();
    btn_submit.setText("查看变量");
    editText=new EditText(getActivity());
    checkBox=new CheckBox(getActivity());
    checkBox.setText("是否为男性");
    container.addView(checkBox);
    container.addView(editText);
    //创建实例
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    RxSharedPreferences rxPreferences = RxSharedPreferences.create(preferences);

    //创建个人
    pre_username = rxPreferences.getString("username");
    pre_sex= rxPreferences.getBoolean("sex", true);

    //绑定
    RxCompoundButton.checkedChanges(checkBox)
            .subscribe(pre_sex.asAction());

    RxTextView.textChanges(editText)
            .flatMap(new Func1<CharSequence, Observable<String>>() {
                @Override
                public Observable<String> call(final CharSequence charSequence) {
                    return Observable.create(new Observable.OnSubscribe<String>() {
                        @Override
                        public void call(Subscriber<? super String> subscriber) {
                            subscriber.onNext(charSequence.toString());
                            subscriber.onCompleted();
                        }
                    });
                }
            })
        .subscribe(pre_username.asAction());
}
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:37,代码来源:RxPreferences_Demo.java

示例8: onCreate

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_report_detail);

    mActivityRecord = (ActivityRecord) getIntent().getSerializableExtra("activity_record");

    if (mActivityRecord == null) {
        finish();
        return;
    }

    ((TextView) findViewById(R.id.time)).setText(Utils.DATE_FORMAT.format(new Date(mActivityRecord.when)));
    String title = getString(R.string.record_cost, mActivityRecord.cost, mActivityRecord.activity_name);
    SpannableString ss = new SpannableString(title);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(mActivityRecord.cost >= StallBuster.getInstance().getThreshold() ? Constants.COLOR_WARNING : Constants.COLOR_NORMAL);
    ss.setSpan(colorSpan, 0, title.indexOf(" "), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    ((TextView) findViewById(R.id.title)).setText(ss);
    mFilterCb = (CheckBox) findViewById(R.id.filter);
    mFilterCb.setText(getString(R.string.cb_hide_system_callbacks_executed_less_than_some_ms, StallBuster.getInstance().getCallbackThreshold()));
    mFilterCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mAdapter.setData(filteredRecords());
        }
    });

    mAdapter = new ReportDetailAdapter();
    RecyclerView container = (RecyclerView) findViewById(R.id.container);
    LinearLayoutManager lm = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    container.setLayoutManager(lm);
    container.addItemDecoration(new SimpleDecoration());
    mAdapter.setData(filteredRecords());
    container.setAdapter(mAdapter);
}
 
开发者ID:zhangjianli,项目名称:StallBuster,代码行数:36,代码来源:ReportDetailActivity.java

示例9: setMultiSelectItems

import android.widget.CheckBox; //导入方法依赖的package包/类
public void setMultiSelectItems(String[] multiSelectItems, boolean[] selectedItems, final OnMultiChoiceClickListener onMultiChoiceClickListener) {
    if (multiSelectItems != null && multiSelectItems.length > 0) {
        if (selectedItems.length != multiSelectItems.length) {
            throw new IllegalArgumentException("multi select items and boolean array size not equal");
        }
        selectableItemsContainer.removeAllViews();
        selectableItemsContainer.setVisibility(View.VISIBLE);
        for (int i = 0; i < multiSelectItems.length; i++) {
            String item = multiSelectItems[i];
            View view = getLayoutInflater().inflate(R.layout.cfdialog_multi_select_item_layout, null);
            CheckBox checkBox = (CheckBox) view.findViewById(R.id.cfdialog_multi_select_item_checkbox);
            checkBox.setText(item);
            checkBox.setChecked(selectedItems[i]);
            final int position = i;
            checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (onMultiChoiceClickListener != null) {
                        onMultiChoiceClickListener.onClick(CFAlertDialog.this, position, isChecked);
                    }
                }
            });
            selectableItemsContainer.addView(view);
        }
    } else {
        selectableItemsContainer.setVisibility(View.GONE);
    }
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:29,代码来源:CFAlertDialog.java

示例10: setUpView

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void setUpView(View view, Context context, Bundle savedInstanceState,
                         final SimpleFormDialog.DialogActions actions,
                         boolean isLastElement, boolean isOnlyElement) {

    checkBox = (CheckBox) view.findViewById(R.id.checkBox);

    // Label
    checkBox.setText(field.getText(context));

    // Check preset
    if (savedInstanceState != null) {
        checkBox.setChecked(savedInstanceState.getBoolean(SAVED_CHECK_STATE));
    } else {
        checkBox.setChecked(field.getInitialState(context));
    }

    // Positive button state for single element forms
    if (isOnlyElement) {
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                actions.updatePosButtonState();
            }
        });
    }

}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:29,代码来源:CheckViewHolder.java

示例11: onCreate

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_symptoms);

    //Programmatically set style due to dynamic layout/instantiation of symptom checkboxes
    final LinearLayout sensationsLayout = (LinearLayout) findViewById(R.id.sensations);
    final LinearLayout colorsLayout = (LinearLayout) findViewById(R.id.colors);
    final LinearLayout othersLayout = (LinearLayout) findViewById(R.id.others);
    LinearLayout[] layouts = {sensationsLayout, colorsLayout, othersLayout};

    final Button finish = (Button) findViewById(R.id.btnDone);
    finish.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setResult();
        }
    });

    for (int z = 0; z < 9; z++)
    {
        conditionIndex.add(z);
    }

    //set onclick listener for every box to disable/enable other possible symptoms
    for (int i = 0; i < checkboxes.length; i++)
    {
        for (int j = 0; j < checkboxes[i].length; j++)
        {
            cb = new CheckBox(this);
            cb.setText(strings[i][j]);
            cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
                    String str = buttonView.getText().toString();
                    // TODO Auto-generated method stub
                    if (isChecked) {
                        current.add(str);
                        counter++;
                    } else {
                        current.remove(str);
                        counter--;
                    }
                    update();
                }
            });
            checkboxes[i][j] = cb;
            layouts[i].addView(checkboxes[i][j]);
        }
    }
}
 
开发者ID:smajko,项目名称:what_are_those_app,代码行数:53,代码来源:SymptomScreen.java

示例12: onAddEditTextToDialogView

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onAddEditTextToDialogView(View dialogView, final EditText editText) {
    super.onAddEditTextToDialogView(dialogView, editText);
    final ViewGroup container = (ViewGroup) editText.getParent();
    if (container != null) {
        final CheckBox cb = new CheckBox(getContext());
        cb.setText(R.string.discoverHttps);
        cb.setChecked(true);

        final Button b = new Button(getContext());
        b.setText(R.string.discoverServer);

        container.addView(b, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        container.addView(cb, ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);

        final ProgressBar p = new ProgressBar(getContext());

        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                b.setEnabled(false);
                ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
                ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(false);

                AsyncTask discoveryTask = new AsyncTask() {
                    @Override
                    protected Object doInBackground(Object[] objects) {
                        ServerDiscovery mDiscovery = new ServerDiscovery((NsdManager) getContext().getSystemService(Context.NSD_SERVICE));
                        mDiscovery.discover(new ServerDiscovery.DiscoveryListener() {
                            @Override
                            public void found(final String serverUrl) {
                                b.post(new Runnable() {
                                    @Override
                                    public void run() {
                                        editText.setText(serverUrl);
                                    }
                                });
                            }

                            @Override
                            public void notFound() {
                                b.post(new Runnable() {
                                    @Override
                                    public void run() {
                                        Toast.makeText(getContext(), getContext().getString(R.string.serverNotFound), Toast.LENGTH_LONG).show();
                                    }
                                });
                            }
                        }, !cb.isChecked(), cb.isChecked());

                        return null;
                    }

                    @Override
                    protected void onPostExecute(Object o) {
                        b.setEnabled(true);
                        ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
                        ((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(true);
                    }
                };
                discoveryTask.execute();
            }
        });

    }

}
 
开发者ID:vbier,项目名称:habpanelviewer,代码行数:70,代码来源:ServerPreference.java

示例13: initViews

import android.widget.CheckBox; //导入方法依赖的package包/类
private void initViews() {
	TextView tvTitle = (TextView)findViewById(R.id.customDlg_tvTitle);
	TextView tvSeparator0 = (TextView)findViewById(R.id.customDialog_tvSeparator0);
	TextView tvInfo = (TextView)findViewById(R.id.customDlg_tvInfo);
	chkNoRepeat = (CheckBox)findViewById(R.id.customDialog_chkNoRepeat);
	TextView tvSeparator1 = (TextView)findViewById(R.id.customDialog_tvSeparator1);
	LinearLayout llytButtons = (LinearLayout)findViewById(R.id.customDialog_llytButtons);
	btnPositive = (Button)findViewById(R.id.customDlg_btnPositive);
	btnPositive.setOnClickListener(this);
	TextView tvSeparator2 = (TextView)findViewById(R.id.customDialog_tvSeparator2);
	btnNatural = (Button)findViewById(R.id.customDlg_btnNatural);
	btnNatural.setOnClickListener(this);
	TextView tvSeparator3 = (TextView)findViewById(R.id.customDialog_tvSeparator3);
	btnNagative = (Button)findViewById(R.id.customDlg_btnNagative);
	btnNagative.setOnClickListener(this);
	
	setCancelable(cancelable);
	if (isEmpty(csTitle)){
		setGone(tvTitle);
		setGone(tvSeparator0);
	}else{
		tvTitle.setText(csTitle);
	}
	tvInfo.setText(csMessage);
	if (isEmpty(csCheckBox)){
		setGone(chkNoRepeat);
	}else{
		chkNoRepeat.setChecked(checkable);
		chkNoRepeat.setText(csCheckBox);
	}
	if (isEmpty(csPositive)){
		setGone(tvSeparator1);
		setGone(llytButtons);
	}else{
		btnPositive.setText(csPositive);
	}
	if (isEmpty(csNatural)){
		setGone(tvSeparator2);
		setGone(btnNatural);
	}else{
		btnNatural.setText(csNatural);
	}
	if (isEmpty(csNagative)){
		setGone(tvSeparator3);
		setGone(btnNagative);
	}else{
		btnNagative.setText(csNagative);
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:50,代码来源:CustomDialog.java

示例14: getItemView

import android.widget.CheckBox; //导入方法依赖的package包/类
public View getItemView(int position, View convertView, ViewHolder holder) {
    CircleImageView iv_avatar = (CircleImageView) holder.getView(R.id.iv_avatar);
    TextView tv_username = (TextView) holder.getView(R.id.tv_username);
    TextView tv_date = (TextView) holder.getView(R.id.tv_date);
    TextView tv_content = (TextView) holder.getView(R.id.tv_content);
    CheckBox cb_fav = (CheckBox) holder.getView(R.id.cb_fav);
    TextView tv_comment = (TextView) holder.getView(R.id.tv_comment);
    TextView tv_share = (TextView) holder.getView(R.id.tv_share);
    ImageView iv_tag = (ImageView) holder.getView(R.id.iv_tag);
    ImageView iv_avatar_tag = (ImageView) holder.getView(R.id.iv_avatar_tag);
    ProgressBar pb_active = (ProgressBar) holder.getView(R.id.pb_active);
    TextView tv_del = (TextView) holder.getView(R.id.tv_del);
    NineGridLayout nineGridLayout = (NineGridLayout) holder.getView(R.id.iv_content);
    final int i = position;
    ((Button) holder.getView(R.id.btn_menu)).setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            TimeLineAdapter.this.showPopupMenu(v, i);
        }
    });
    Post post = (Post) this.data.get(position);
    tv_username.setText(post.user != null ? post.user.nickname : "");
    tv_date.setText(DateHelper.timezoneFormat(post.created_at, "MM-dd HH:mm"));
    tv_content.setText(post.body);
    TimeLineUtility.addLinks(tv_content);
    loadAvatar(iv_avatar, post);
    loadContentImg(nineGridLayout, post);
    cb_fav.setText(post.envious_count + "");
    tv_comment.setText(post.comment_count + "");
    cb_fav.setChecked(isFav(post));
    setUpTopTag(iv_tag, post);
    setUpAvatarTag(pb_active, iv_avatar_tag, post);
    setUpOwner(tv_del, post);
    AvartaClickListener listener = new AvartaClickListener(post.user.nickname);
    iv_avatar.setOnClickListener(listener);
    tv_username.setOnClickListener(listener);
    cb_fav.setOnClickListener(new FavClickListener(position));
    tv_comment.setOnClickListener(new CommentClickListener(post, position));
    tv_share.setOnClickListener(new ShareClickListener(post));
    convertView.setOnLongClickListener(new LongClickCopy(post));
    return convertView;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:42,代码来源:TimeLineAdapter.java

示例15: barcodeResult

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public void barcodeResult(BarcodeResult result) {
    if(result.getText() == null) {
        return;
    }

    byte[] rawBytes = new byte[0];
    try {
        rawBytes = result.getText().getBytes("ISO-8859-1");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    if (splittedFile.isPartAdded(rawBytes)) {
        Toast.makeText(context, "Ignored: " + String.valueOf(rawBytes[0]), Toast.LENGTH_SHORT).show();
        return;
    }

    QRCode qrCode = splittedFile.addPart(rawBytes);

    if (splittedFile.isCompleted()) {
        Intent intent = new Intent(getBaseContext(), SaveActivity.class);
        intent.putExtra("MERGED_FILE", splittedFile.getMergedFile());
        intent.putExtra("FILENAME", splittedFile.getFilename());
        startActivity(intent);
        finish();
    }

    if (checkBoxes.size() == 0) {
        LinearLayout progress = (LinearLayout) findViewById(R.id.progress);
        for (int i = 0; i < splittedFile.getPiecesQuantity(); i++) {
            CheckBox checkBox = new CheckBox(context);
            checkBox.setText(String.format(Locale.getDefault(), "%d", i + 1));
            checkBox.setClickable(false);
            progress.addView(checkBox);
            checkBoxes.add(checkBox);
        }
        TextView first_scan_text = (TextView) findViewById(R.id.first_scan_text);
        first_scan_text.setVisibility(View.GONE);
    }

    checkBoxes.get(qrCode.getMetadata().getNumber() - 1).setChecked(true);
}
 
开发者ID:cgimenes,项目名称:binqr-mobile,代码行数:44,代码来源:ScanActivity.java


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