android.widget.RadioButton Java Examples

The following examples show how to use android.widget.RadioButton. 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: DownloadSettingsActivity.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private void initViews() {
    mStoreLocText = (TextView)findViewById(R.id.store_loc_txt);
    mStoreSizeText = (TextView)findViewById(R.id.store_size);
    mOpenFileText = (TextView)findViewById(R.id.open_file_txt);
    mClearDownloadText = (TextView)findViewById(R.id.clear_download_cache);
    mBtn1 = (RadioButton)findViewById(R.id.btn1);
    mBtn2 = (RadioButton)findViewById(R.id.btn2);
    mBtn3 = (RadioButton)findViewById(R.id.btn3);
    mBtn4 = (RadioButton)findViewById(R.id.btn4);
    mBtn5 = (RadioButton)findViewById(R.id.btn5);
    mBtn11 = (RadioButton)findViewById(R.id.btn11);
    mBtn12 = (RadioButton)findViewById(R.id.btn12);

    mStoreLocText.setText(
            VideoDownloadManager.getInstance().getCacheFilePath());
    mOpenFileText.setOnClickListener(this);
    mClearDownloadText.setOnClickListener(this);
    mBtn1.setOnClickListener(this);
    mBtn2.setOnClickListener(this);
    mBtn3.setOnClickListener(this);
    mBtn4.setOnClickListener(this);
    mBtn5.setOnClickListener(this);
    mBtn11.setOnClickListener(this);
    mBtn12.setOnClickListener(this);
}
 
Example #2
Source File: AdvancedOptionsDialogFragment.java    From reflow-animator with Apache License 2.0 6 votes vote down vote up
@OnCheckedChanged({ R.id.target_align_start, R.id.target_align_center, R.id.target_align_end })
void onTargetAlignmentChanged(RadioButton button, boolean isChecked) {
    if (isChecked) {
        int alignment = Gravity.NO_GRAVITY;
        switch (button.getId()) {
            case R.id.target_align_start:
                alignment = Gravity.START;
                break;
            case R.id.target_align_center:
                alignment = Gravity.CENTER_HORIZONTAL;
                break;
            case R.id.target_align_end:
                alignment = Gravity.END;
                break;
        }
        onUpdateListener.updateTargetTextAlignment(alignment);
    }
}
 
Example #3
Source File: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final View view = convertView != null ? convertView
            : mInflater.inflate(mTextViewResourceId, null);
    if (position < 0 || position >= mItemsList.size()) return view;
    final ImeSubtypeListItem item = mItemsList.get(position);
    final CharSequence imeName = item.mImeName;
    final CharSequence subtypeName = item.mSubtypeName;
    final TextView firstTextView = (TextView)view.findViewById(android.R.id.text1);
    final TextView secondTextView = (TextView)view.findViewById(android.R.id.text2);
    if (TextUtils.isEmpty(subtypeName)) {
        firstTextView.setText(imeName);
        secondTextView.setVisibility(View.GONE);
    } else {
        firstTextView.setText(subtypeName);
        secondTextView.setText(imeName);
        secondTextView.setVisibility(View.VISIBLE);
    }
    final RadioButton radioButton =
            (RadioButton)view.findViewById(com.android.internal.R.id.radio);
    radioButton.setChecked(position == mCheckedItem);
    return view;
}
 
Example #4
Source File: MDTintHelper.java    From talk-android with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
public static void setTint(RadioButton radioButton, int color) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_checked},
            new int[]{android.R.attr.state_checked}
    }, new int[]{
            DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
            color
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable d = DrawableCompat.wrap(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material));
        DrawableCompat.setTintList(d, sl);
        radioButton.setButtonDrawable(d);
    }
}
 
Example #5
Source File: RecyclerViewScrollActivity.java    From AndroidDemo with MIT License 6 votes vote down vote up
private void initTab() {
    int padding = Tools.dip2px(this, 10);
    for (int i = 0; i < 20; i++) {
        RadioButton rb = new RadioButton(this);
        rb.setPadding(padding, 0, padding, 0);
        rb.setButtonDrawable(null);
        rb.setGravity(Gravity.CENTER);
        rb.setTag(i * 5);
        rb.setText("Group " + i);
        rb.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
        try {
            rb.setTextColor(getResources().getColorStateList(R.color.bg_tab_text));
        } catch (Exception e) {
            e.printStackTrace();
        }
        rb.setCompoundDrawablesWithIntrinsicBounds(null, null, null, getResources().getDrawable(R.drawable.bg_block_tab));
        rb.setOnCheckedChangeListener(onCheckedChangeListener);
        rg_tab.addView(rb);
    }
    ((RadioButton) rg_tab.getChildAt(0)).setChecked(true);
}
 
Example #6
Source File: HoriActivity.java    From AdvancedTextView with Apache License 2.0 6 votes vote down vote up
private void initView() {
    selectableTextView = (SelectableTextView) findViewById(R.id.ctv_content);
    selectableTextView.setText(Html.fromHtml(StringContentUtil.str_hanzi).toString());
    selectableTextView.clearFocus();
    selectableTextView.setTextJustify(true);
    selectableTextView.setForbiddenActionMenu(false);
    selectableTextView.setCustomActionMenuCallBack(this);
    selectableTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(HoriActivity.this, "SelectableTextView 的onClick事件", Toast.LENGTH_SHORT).show();
        }
    });

    rg_text_gravity = (RadioGroup) findViewById(R.id.rg_text_gravity);
    rg_text_content = (RadioGroup) findViewById(R.id.rg_text_content);
    ((RadioButton) findViewById(R.id.rb_justify)).setChecked(true);
    ((RadioButton) findViewById(R.id.rb_hanzi)).setChecked(true);
    rg_text_gravity.setOnCheckedChangeListener(this);
    rg_text_content.setOnCheckedChangeListener(this);
}
 
Example #7
Source File: QD.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
public void clear() {
	switch(questionDef.getControlType()) {
	case org.javarosa.core.model.Constants.CONTROL_INPUT:
		((EditText) answerHolder).setText("");
		break;
	case org.javarosa.core.model.Constants.CONTROL_SELECT_ONE:
		RadioGroup rg = ((RadioGroup) answerHolder);
		for(int r = 0; r < selectChoiceText.size(); r++) {
			((RadioButton) rg.getChildAt(r)).setChecked(false);
		}
		break;
	case org.javarosa.core.model.Constants.CONTROL_SELECT_MULTI:
		LinearLayout ll = ((LinearLayout) answerHolder);

		for(int c = 0; c < selectChoiceText.size(); c++) {
			((CheckBox) ll.getChildAt(c)).setChecked(false);				
		}

		answerHolder = ll;
		break;
	case org.javarosa.core.model.Constants.CONTROL_AUDIO_CAPTURE:
		((ODKSeekBar) answerHolder).rawAudioData = null;
		break;

	}
}
 
Example #8
Source File: EmoticonView.java    From emoji with Apache License 2.0 6 votes vote down vote up
public void init(Context mContext, OnEmoticonTapListener mTapListener, Resources resources) {
	this.mContext = mContext;
	this.mTapListener = mTapListener;
	this.resources = resources;
	parser = EmojiParser.getInstance(mContext);
	mEmojiGridView = (GridView) this.findViewById(R.id.message_facebar_gv_emotes);
	adapter = new EmojiAdapter();
	mEmojiGridView.setAdapter(adapter);
	mEmojiGridView.setOnItemClickListener(this);
	mEmojiGroup = (RadioGroup) findViewById(R.id.message_facebar_radiobutton_type);
	mEmojiGroup.setOnCheckedChangeListener(this);
	mEmojiRadio1 = (RadioButton) this.findViewById(R.id.emote_radio_1);
	mEmojiRadio1.setOnClickListener(this);
	mEmojiRadio1.setSelected(true);
	mEmojiRadio1.setChecked(true);
	mEmojiRadio2 = (RadioButton) this.findViewById(R.id.emote_radio_2);
	mEmojiRadio2.setOnClickListener(this);
	mEmojiRadio3 = (RadioButton) this.findViewById(R.id.emote_radio_3);
	mEmojiRadio3.setOnClickListener(this);
	mEmojiRadio4 = (RadioButton) this.findViewById(R.id.emote_radio_4);
	mEmojiRadio4.setOnClickListener(this);
	mEmojiRadio5 = (RadioButton) this.findViewById(R.id.emote_radio_5);
	mEmojiRadio5.setOnClickListener(this);
	mEmojiDelte = (ImageView) this.findViewById(R.id.emote_radio_delete);
	mEmojiDelte.setOnClickListener(this);
}
 
Example #9
Source File: ViewUtil.java    From sa-sdk-android with Apache License 2.0 6 votes vote down vote up
static boolean isTrackEvent(View view, boolean isFromUser) {
    if (view instanceof CheckBox) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof RadioButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof ToggleButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof CompoundButton) {
        if (!isFromUser) {
            return false;
        }
    }
    if (view instanceof RatingBar) {
        if (!isFromUser) {
            return false;
        }
    }
    return true;
}
 
Example #10
Source File: PickerView.java    From PickerView with Apache License 2.0 6 votes vote down vote up
private void initView() {
    pickerTitleName = (TextView) view.findViewById(R.id.pickerTitleName);
    pickerConfirm = (TextView) view.findViewById(R.id.pickerConfirm);
    groupSelect = (RadioGroup) view.findViewById(R.id.groupSelect);
    mTextFirst = (RadioButton) view.findViewById(R.id.mTextFirst);
    mTextSecond = (RadioButton) view.findViewById(R.id.mTextSecond);
    mTextThird = (RadioButton) view.findViewById(R.id.mTextThird);
    mTextFourth = (RadioButton) view.findViewById(R.id.mTextFourth);
    pickerList = (ListView) view.findViewById(R.id.pickerList);
    emptyView = (TextView) view.findViewById(R.id.empty_data_hints);
    pickerList.setEmptyView(view.findViewById(R.id.picker_list_empty_data));
    mTextFirst.setOnClickListener(this);
    mTextSecond.setOnClickListener(this);
    mTextThird.setOnClickListener(this);
    pickerConfirm.setOnClickListener(this);
    if (!TextUtils.isEmpty(pickerData.getPickerTitleName())){
        pickerTitleName.setText(pickerData.getPickerTitleName());
    }
}
 
Example #11
Source File: Easel.java    From andela-crypto-app with Apache License 2.0 6 votes vote down vote up
/**
 * Tint the radio button
 *
 * @param radioButton the radio button
 * @param color       the color
 */
public static void tint(@NonNull RadioButton radioButton, @ColorInt int color) {
    final int disabledColor = getDisabledColor(radioButton.getContext());
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            getThemeAttrColor(radioButton.getContext(), R.attr.colorControlNormal),
            color,
            disabledColor,
            disabledColor
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, sl);
        radioButton.setButtonDrawable(d);
    }
}
 
Example #12
Source File: MainActivity.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
protected void siteChanged(RadioGroup group, int checkedId) {
    if (checkedId == -1) {
        return;
    }
    RadioButton button = (RadioButton) group.findViewById(checkedId);
    Site site = (Site) button.getTag();
    if (site != null) {
        App.setSiteUrl(site.getUrl());
    }
    if (site == null) {
        group.clearCheck();
        openSettingsActivity();
    } else if (!site.getUrl().equals(mCurrentSiteUrl)) { // TODO 第一次启动 加载上次查看的url。
        mDrawerPosition = ListView.INVALID_POSITION;
        mCurrentSite = site;
        mCurrentSiteUrl = site.getUrl();
        PrefsUtils.setCurrentSiteUrl(mCurrentSiteUrl);
        App.setLogin(false);
        clearDatabase();
        // 登陆完成后,再加载其他信息
        loadUserInfo(site, false);
    } else {
        setupUserInfo(mUser);
    }
    getActionBar().setSubtitle(mCurrentSiteUrl);
}
 
Example #13
Source File: CameraConfigFragment.java    From PLDroidMediaStreaming with Apache License 2.0 6 votes vote down vote up
private CameraConfig buildCameraConfig() {
    CameraConfig cameraConfig = new CameraConfig();
    View root = getView();

    cameraConfig.mFrontFacing = ((RadioButton) root.findViewById(R.id.facing_front)).isChecked();
    Spinner sizeLevelSpinner = (Spinner) root.findViewById(R.id.preview_size_level_spinner);
    cameraConfig.mSizeLevel = PREVIEW_SIZE_LEVEL_PRESETS_MAPPING[sizeLevelSpinner.getSelectedItemPosition()];
    Spinner sizeRatioSpinner = (Spinner) root.findViewById(R.id.preview_size_ratio_spinner);
    cameraConfig.mSizeRatio = PREVIEW_SIZE_RATIO_PRESETS_MAPPING[sizeRatioSpinner.getSelectedItemPosition()];
    Spinner focusModeSpinner = (Spinner) root.findViewById(R.id.focus_mode_spinner);
    cameraConfig.mFocusMode = FOCUS_MODE_PRESETS_MAPPING[focusModeSpinner.getSelectedItemPosition()];
    cameraConfig.mIsFaceBeautyEnabled = ((CheckBox) root.findViewById(R.id.face_beauty)).isChecked();
    cameraConfig.mIsCustomFaceBeauty = ((CheckBox) root.findViewById(R.id.external_face_beauty)).isChecked();
    cameraConfig.mContinuousAutoFocus = ((CheckBox) root.findViewById(R.id.continuous_auto_focus)).isChecked();
    cameraConfig.mPreviewMirror = ((CheckBox) root.findViewById(R.id.preview_mirror)).isChecked();
    cameraConfig.mEncodingMirror = ((CheckBox) root.findViewById(R.id.encoding_mirror)).isChecked();

    return cameraConfig;
}
 
Example #14
Source File: SettingInfoActivity.java    From WifiChat with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void initViews() {

    mIvAvater = (ImageView) findViewById(R.id.setting_my_avater_img);
    mEtNickname = (EditText) findViewById(R.id.setting_my_nickname);
    mRgGender = (RadioGroup) findViewById(R.id.setting_baseinfo_rg_gender);
    mHtvConstellation = (TextView) findViewById(R.id.setting_birthday_htv_constellation);
    mHtvAge = (TextView) findViewById(R.id.setting_birthday_htv_age);
    mDpBirthday = (DatePicker) findViewById(R.id.setting_birthday_dp_birthday);

    mRbBoy = (RadioButton) findViewById(R.id.setting_baseinfo_rb_male);
    mRbGirl = (RadioButton) findViewById(R.id.setting_baseinfo_rb_female);

    mBtnBack = (Button) findViewById(R.id.setting_btn_back);
    mBtnNext = (Button) findViewById(R.id.setting_btn_next);

}
 
Example #15
Source File: MainActivity.java    From SmallGdufe-Android with GNU General Public License v3.0 6 votes vote down vote up
@OnClick({ R.id.rd_home, R.id.rd_features,R.id.rd_me }) public void onRadioButtonClicked(RadioButton radioButton) {
    boolean checked = radioButton.isChecked();
    switch (radioButton.getId()) {
        case R.id.rd_home:
            if (checked) {
                fUtil.show(mFragments.get(0));break;
            }
        case R.id.rd_features:
            if (checked) {
                fUtil.show(mFragments.get(1));break;
            }
        case R.id.rd_social:
            if (checked) {
                fUtil.show(mFragments.get(2));break;
            }
        case R.id.rd_me:
            if (checked) {
                if(isAlpha){
                    fUtil.show(mFragments.get(3));break;
                }else{
                    fUtil.show(mFragments.get(2));break;
                }
            }
    }
}
 
Example #16
Source File: ChannelSearchActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	RadioButton radio = (RadioButton)findViewById(R.id.personalRadio);
	radio.setText("My Channels");
   	
	Spinner sortSpin = (Spinner) findViewById(R.id.sortSpin);
	@SuppressWarnings("unchecked")
	ArrayAdapter adapter = new ArrayAdapter(this,
               android.R.layout.simple_spinner_dropdown_item, new String[]{
       			"connects",
       			"connects today",
       			"connects this week",
       			"connects this month",
       			"last connect",
       			"name",
       			"date",
           		"messages",
           		"users online",
           		"thumbs up",
           		"thumbs down",
           		"stars"
       });
	sortSpin.setAdapter(adapter);
}
 
Example #17
Source File: GravityActivity.java    From ans-android-sdk with GNU General Public License v3.0 5 votes vote down vote up
private void initView() {
    gravityBt = (Button) findViewById(R.id.gravity_bt);

    alignLeftRb = (RadioButton) findViewById(R.id.align_left_rb);
    alignRightRb = (RadioButton) findViewById(R.id.align_right_rb);
    centerHoriRb = (RadioButton) findViewById(R.id.center_hori_rb);
    toRightRb = (RadioButton) findViewById(R.id.to_right_rb);
    toLeftRb = (RadioButton) findViewById(R.id.to_left_rb);

    alignAboveRb = (RadioButton) findViewById(R.id.align_above_rb);
    alignBottomRb = (RadioButton) findViewById(R.id.align_bottom_rb);
    centerVertRb = (RadioButton) findViewById(R.id.center_vert_rb);
    toBottomRb = (RadioButton) findViewById(R.id.to_bottom_rb);
    toAboveRb = (RadioButton) findViewById(R.id.to_above_rb);
}
 
Example #18
Source File: SearchableListAdapter.java    From boilr with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onTouch(View view, MotionEvent event) {
	switch (event.getAction()) {
		case MotionEvent.ACTION_UP:
			RadioButton radioButton = (RadioButton)view.findViewById(R.id.searchable_radio_button);
			radioButton.setChecked(true);
			
			view.setBackgroundColor(searchableListPreference.getContext().getResources().getColor(R.color.highlightblue));
			
			TextView textView = (TextView) view.findViewById(R.id.searchable_text_view);
			CharSequence[] values = searchableListPreference.getEntryValues();

			CharSequence[] entries = searchableListPreference.getEntries();
			CharSequence value = null;
			for (int i = 0; i < entries.length; i++) {
				if(entries[i].equals(textView.getText())) {
					value = values[i];
					break;
				}
			}
			searchableListPreference.setValue((String) value);
			searchableListPreference.getOnPreferenceChangeListener().onPreferenceChange(searchableListPreference, value);
			searchableListPreference.getDialog().dismiss();
			break;
		case MotionEvent.ACTION_MOVE:
			InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
					Context.INPUT_METHOD_SERVICE);
			imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
			break;
	}
	return false;
}
 
Example #19
Source File: AddTaskActivity.java    From android-dev-challenge with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_task);

    // Initialize to highest mPriority by default (mPriority = 1)
    ((RadioButton) findViewById(R.id.radButton1)).setChecked(true);
    mPriority = 1;
}
 
Example #20
Source File: AddressViewBinder.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
ItemViewHolder(View view) {
    super(view);
    cbDefault = (RadioButton) view.findViewById(R.id.cbDefault);
    tvName = (TextView) view.findViewById(R.id.tvName);
    tvPhoneNumber = (TextView) view.findViewById(R.id.tvPhoneNumber);
    tvAddress = (TextView) view.findViewById(R.id.tvAddress);
    llEditorAddress = (TextView) view.findViewById(R.id.llEditorAddress);
    llDeleteAddress = (TextView) view.findViewById(R.id.llDeleteAddress);
}
 
Example #21
Source File: ListWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private int getCheckedId() {
    for (RadioButton button : this.buttons) {
        if (button.isChecked()) {
            return button.getId();
        }
    }
    return -1;
}
 
Example #22
Source File: SwitchButton.java    From SwitchButton with Apache License 2.0 5 votes vote down vote up
private RadioButton createRadioView() {
	RadioButton mRadioButton = new RadioButton(getContext(), null, mRadioStyle > 0 ? mRadioStyle : android.R.attr.radioButtonStyle);
	if (mRadioStyle == 0) {
		mRadioButton.setGravity(Gravity.CENTER);
		mRadioButton.setEllipsize(TruncateAt.END);
	}
	if (mTextColor != null)
		mRadioButton.setTextColor(mTextColor);
	if (textSize > 0)
		mRadioButton.setTextSize(textSize);
	return mRadioButton;
}
 
Example #23
Source File: InflectionQuizActivity.java    From aedict with GNU General Public License v3.0 5 votes vote down vote up
private int getSelected() {
	for (final Map.Entry<Integer, Integer> e : OPTION_TO_ID.entrySet()) {
		final RadioButton btn = (RadioButton) findViewById(e.getValue());
		if (btn.isChecked()) {
			return e.getKey();
		}
	}
	throw new AssertionError();
}
 
Example #24
Source File: Dialog.java    From PocketMaps with MIT License 5 votes vote down vote up
public static void showUnitTypeSelector(Activity activity)
{
  AlertDialog.Builder builder1 = new AlertDialog.Builder(activity);
  builder1.setTitle(R.string.units);
  builder1.setCancelable(true);
  
  final RadioButton rb1 = new RadioButton(activity.getBaseContext());
  rb1.setText(R.string.units_metric);

  final RadioButton rb2 = new RadioButton(activity.getBaseContext());
  rb2.setText(R.string.units_imperal);
  
  final RadioGroup rg = new RadioGroup(activity.getBaseContext());
  rg.addView(rb1);
  rg.addView(rb2);
  rg.check(Variable.getVariable().isImperalUnit() ? rb2.getId() : rb1.getId());
  
  builder1.setView(rg);
  OnClickListener listener = new OnClickListener()
  {
    @Override
    public void onClick(DialogInterface dialog, int buttonNr)
    {
      Variable.getVariable().setImperalUnit(rb2.isChecked());
      Variable.getVariable().saveVariables(Variable.VarType.Base);
    }
  };
  builder1.setPositiveButton(R.string.ok, listener);
  AlertDialog alert11 = builder1.create();
  alert11.show();
}
 
Example #25
Source File: DistilledPagePrefsView.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a DistilledPagePrefsView.
 *
 * @param context Context for acquiring resources.
 * @param attrs Attributes from the XML layout inflation.
 */
public DistilledPagePrefsView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mDistilledPagePrefs = DomDistillerServiceFactory.getForProfile(
            Profile.getLastUsedProfile()).getDistilledPagePrefs();
    mColorModeButtons = new EnumMap<Theme, RadioButton>(Theme.class);
    mPercentageFormatter = NumberFormat.getPercentInstance(Locale.getDefault());
}
 
Example #26
Source File: SegmentView.java    From SegmentView with MIT License 5 votes vote down vote up
public void addTab(String title) {
    RadioButton radioButton = (RadioButton) LayoutInflater.from(getContext()).inflate(
            R.layout.radio_button_item, this, false);
    radioButton.setId(ids++);
    radioButton.setText(title);
    // 添加到当前ViewGroup中
    this.addView(radioButton);
}
 
Example #27
Source File: EnterKeyActivity.java    From google-authenticator-android with Apache License 2.0 5 votes vote down vote up
/** Called when the activity is first created */
@Override
public void onCreate(Bundle savedInstanceState) {
  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
  if (preferences.getBoolean(AuthenticatorActivity.KEY_DARK_MODE_ENABLED, false)) {
    setTheme(R.style.AuthenticatorTheme_NoActionBar_Dark);
  } else {
    setTheme(R.style.AuthenticatorTheme_NoActionBar);
  }

  super.onCreate(savedInstanceState);
  setContentView(R.layout.enter_key);

  setSupportActionBar((Toolbar) findViewById(R.id.enter_key_toolbar));
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setDisplayShowHomeEnabled(true);

  // Find all the views on the page
  keyEntryField = (EditText) findViewById(R.id.key_value);
  accountName = (EditText) findViewById(R.id.account_name);
  keyEntryFieldInputLayout = (TextInputLayout) findViewById(R.id.key_value_input_layout);

  typeTotp = (RadioButton) findViewById(R.id.type_choice_totp);
  typeHotp = (RadioButton) findViewById(R.id.type_choice_hotp);

  typeTotp.setText(getResources().getStringArray(R.array.type)[OtpType.TOTP.value]);
  typeHotp.setText(getResources().getStringArray(R.array.type)[OtpType.HOTP.value]);

  keyEntryFieldInputLayout.setErrorEnabled(true);

  // Set listeners
  keyEntryField.addTextChangedListener(this);

  findViewById(R.id.add_account_button_enter_key)
      .setOnClickListener(addButtonEnterKeyOnClickListener);
}
 
Example #28
Source File: ObservationFilterActivity.java    From mage-android with Apache License 2.0 5 votes vote down vote up
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
	int filter = Integer.parseInt(buttonView.getTag().toString());
	((RadioButton) findViewById(android.R.id.content).findViewWithTag(timeFilter.toString())).setChecked(false);
	timeFilter = filter;
	buttonView.setChecked(true);
	showOrHideCustomWindow();
	setFilter();
}
 
Example #29
Source File: AddTaskActivity.java    From android-dev-challenge with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_task);

    // Initialize to highest mPriority by default (mPriority = 1)
    ((RadioButton) findViewById(R.id.radButton1)).setChecked(true);
    mPriority = 1;
}
 
Example #30
Source File: MainActivity.java    From ImageLoadPK with Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.center, R.id.centerCrop, R.id.centerInside, R.id.fitCenter, R.id.fitStart, R.id.fitEnd, R.id.fitXY, R.id.matrix})
public void onClick(View view) {
    if (view instanceof RadioButton) {
        isSelected((RadioButton) view);
    }
    switch (view.getId()) {
        case R.id.center:
            setScaleType(ImageView.ScaleType.CENTER);
            break;
        case R.id.centerCrop:
            setScaleType(ImageView.ScaleType.CENTER_CROP);
            break;
        case R.id.centerInside:
            setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            break;
        case R.id.fitCenter:
            setScaleType(ImageView.ScaleType.FIT_CENTER);
            break;
        case R.id.fitStart:
            setScaleType(ImageView.ScaleType.FIT_START);
            break;
        case R.id.fitEnd:
            setScaleType(ImageView.ScaleType.FIT_END);
            break;
        case R.id.fitXY:
            setScaleType(ImageView.ScaleType.FIT_XY);
            break;
        case R.id.matrix:
            setScaleType(ImageView.ScaleType.MATRIX);
            break;
    }
}