Java Code Examples for android.widget.RadioButton#setClickable()

The following examples show how to use android.widget.RadioButton#setClickable() . 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: WizardFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
private void createRadioButtons() {
  // set button dimension
  int buttonSize = AptoideUtils.ScreenU.getPixelsForDip(10, getResources());
  ViewGroup.LayoutParams buttonLayoutParams = new RadioGroup.LayoutParams(buttonSize, buttonSize);

  // set button margin
  int buttonMargin = AptoideUtils.ScreenU.getPixelsForDip(2, getResources());
  ViewGroup.MarginLayoutParams marginLayoutParams =
      (ViewGroup.MarginLayoutParams) buttonLayoutParams;
  marginLayoutParams.setMargins(buttonMargin, buttonMargin, buttonMargin, buttonMargin);

  final int pages = viewPagerAdapter.getCount();
  wizardButtons = new ArrayList<>(pages);
  Context context = getContext();
  for (int i = 0; i < pages; i++) {
    RadioButton radioButton = new RadioButton(context);
    radioButton.setLayoutParams(buttonLayoutParams);
    radioButton.setButtonDrawable(android.R.color.transparent);
    radioButton.setBackgroundResource(R.drawable.wizard_custom_indicator);
    radioButton.setClickable(false);
    radioGroup.addView(radioButton);
    wizardButtons.add(radioButton);
  }
}
 
Example 2
Source File: ViewPagerIndicator.java    From EtsyBlur with Apache License 2.0 6 votes vote down vote up
public void setPageCount(int pageCount) {
    this.pageCount = pageCount;
    removeAllViews();
    for (int i = 0; i < pageCount; i++) {
        RadioButton rb = new RadioButton(getContext());
        rb.setFocusable(false);
        rb.setClickable(false);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            Drawable d = ContextCompat.getDrawable(getContext(), R.drawable.indicator);
            rb.setButtonDrawable(d);
            LinearLayout.LayoutParams params = generateDefaultLayoutParams();
            params.width = d.getIntrinsicWidth();
            params.height = d.getIntrinsicHeight();
            rb.setLayoutParams(params);
        } else {
            rb.setButtonDrawable(R.drawable.indicator);
        }
        addView(rb);
    }
    setCurrentPosition(-1);
}
 
Example 3
Source File: AlbumVideoController.java    From letv with Apache License 2.0 5 votes vote down vote up
private void setStreamButtonEnableByLevel(int level) {
    boolean z;
    boolean z2 = true;
    this.mLowButton.setClickable(level != 0);
    RadioButton radioButton = this.mStandardButton;
    if (level != 1) {
        z = true;
    } else {
        z = false;
    }
    radioButton.setClickable(z);
    radioButton = this.mHighButton;
    if (level != 2) {
        z = true;
    } else {
        z = false;
    }
    radioButton.setClickable(z);
    radioButton = this.mSuperHighButton;
    if (level != 3) {
        z = true;
    } else {
        z = false;
    }
    radioButton.setClickable(z);
    radioButton = this.m720Button;
    if (level != 4) {
        z = true;
    } else {
        z = false;
    }
    radioButton.setClickable(z);
    RadioButton radioButton2 = this.m1080Button;
    if (level == 5) {
        z2 = false;
    }
    radioButton2.setClickable(z2);
}
 
Example 4
Source File: RadioButtonWithDescription.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for inflating via XML.
 */
public RadioButtonWithDescription(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater.from(context).inflate(R.layout.radio_button_with_description, this, true);

    mRadioButton = (RadioButton) findViewById(R.id.radio_button);
    mTitle = (TextView) findViewById(R.id.title);
    mDescription = (TextView) findViewById(R.id.description);

    if (attrs != null) applyAttributes(attrs);

    // We want RadioButtonWithDescription to handle the clicks itself.
    mRadioButton.setClickable(false);
    setOnClickListener(this);
}
 
Example 5
Source File: RadioButtonWithDescription.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for inflating via XML.
 */
public RadioButtonWithDescription(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater.from(context).inflate(R.layout.radio_button_with_description, this, true);

    mRadioButton = (RadioButton) findViewById(R.id.radio_button);
    mTitle = (TextView) findViewById(R.id.title);
    mDescription = (TextView) findViewById(R.id.description);

    if (attrs != null) applyAttributes(attrs);

    // We want RadioButtonWithDescription to handle the clicks itself.
    mRadioButton.setClickable(false);
    setOnClickListener(this);
}
 
Example 6
Source File: RadioButtonWithDescription.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for inflating via XML.
 */
public RadioButtonWithDescription(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater.from(context).inflate(R.layout.radio_button_with_description, this, true);

    mRadioButton = (RadioButton) findViewById(R.id.radio_button);
    mTitle = (TextView) findViewById(R.id.title);
    mDescription = (TextView) findViewById(R.id.description);

    if (attrs != null) applyAttributes(attrs);

    // We want RadioButtonWithDescription to handle the clicks itself.
    mRadioButton.setClickable(false);
    setOnClickListener(this);
}
 
Example 7
Source File: SettingFragment.java    From SeeWeather with Apache License 2.0 4 votes vote down vote up
private void showIconDialog() {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogLayout = inflater.inflate(R.layout.dialog_icon, (ViewGroup) getActivity().findViewById(R.id.dialog_root));
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(dialogLayout);
    final AlertDialog alertDialog = builder.create();

    LinearLayout layoutTypeOne = (LinearLayout) dialogLayout.findViewById(R.id.layout_one);
    layoutTypeOne.setClickable(true);
    RadioButton radioTypeOne = (RadioButton) dialogLayout.findViewById(R.id.radio_one);
    LinearLayout layoutTypeTwo = (LinearLayout) dialogLayout.findViewById(R.id.layout_two);
    layoutTypeTwo.setClickable(true);
    RadioButton radioTypeTwo = (RadioButton) dialogLayout.findViewById(R.id.radio_two);
    TextView done = (TextView) dialogLayout.findViewById(R.id.done);

    radioTypeOne.setClickable(false);
    radioTypeTwo.setClickable(false);

    alertDialog.show();

    switch (mSharedPreferenceUtil.getIconType()) {
        case 0:
            radioTypeOne.setChecked(true);
            radioTypeTwo.setChecked(false);
            break;
        case 1:
            radioTypeOne.setChecked(false);
            radioTypeTwo.setChecked(true);
            break;
    }

    layoutTypeOne.setOnClickListener(v -> {
        radioTypeOne.setChecked(true);
        radioTypeTwo.setChecked(false);
    });

    layoutTypeTwo.setOnClickListener(v -> {
        radioTypeOne.setChecked(false);
        radioTypeTwo.setChecked(true);
    });

    done.setOnClickListener(v -> {
        mSharedPreferenceUtil.setIconType(radioTypeOne.isChecked() ? 0 : 1);
        String[] iconsText = getResources().getStringArray(R.array.icons);
        mChangeIcons.setSummary(radioTypeOne.isChecked() ? iconsText[0] :
            iconsText[1]);
        alertDialog.dismiss();
        Snackbar.make(getView(), "切换成功,重启应用生效",
            Snackbar.LENGTH_INDEFINITE).setAction("重启",
            v1 -> {
                Intent intent = new Intent(getActivity(), MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                getActivity().startActivity(intent);
                getActivity().finish();
                RxBus.getDefault().post(new ChangeCityEvent());
            }).show();
    });
}