JakeWharton / butterknife

Bind Android views and callbacks to fields and methods.
http://jakewharton.github.io/butterknife/
Apache License 2.0
25.56k stars 4.6k forks source link

Proposal to add OnCheckedChanged for RadioGroup. #148

Open jstefanowski opened 10 years ago

jstefanowski commented 10 years ago

Butterknife could probably also include OnCheckedChanged listener injection for RadioGroups.

ghost commented 10 years ago

I want to use this in order to inject OnCheckedChangedListener into RadioGroup.

alexandrepossebom commented 9 years ago

+1

titanseason commented 9 years ago

+1 for this

SoCmodder commented 9 years ago

+1

FabianShallari commented 9 years ago

+1

LLin233 commented 9 years ago

+1 make it better

lordmegamax commented 9 years ago

+1

suciudaniel commented 9 years ago

+1

shukob commented 9 years ago

+1

kiosoftinc commented 9 years ago

+1

cesarferreira commented 9 years ago

+1

ticofab commented 9 years ago

Hi, what is the status of this? By trying to @Bind(R.id.radio_group_id) RadioGroup mMyRadioGroup; I get a android.widget.RadioGroup cannot be cast to android.widget.CompoundButton.

JakeWharton commented 9 years ago

@ticofab that is unrelated and sounds like you just need to clean your project.

peterbartos commented 9 years ago

Temporary workaround is to bind all radio buttons to the same callback and then check which is selected:

@OnClick({R.id.radio_button1, R.id.radio_button2})
public void radioGroupUpdate() {
    radio1.isChecked() ? ....
}
ticofab commented 9 years ago

thanks @JakeWharton and @peterbartos for your comments!

akhy commented 9 years ago

+1

radu-topor commented 9 years ago

+1

Rainer-Lang commented 8 years ago

+1

rodrigohenriques commented 8 years ago

+1

abhijitnukalapati commented 8 years ago

+1

audiebant commented 8 years ago

+1

sathishsr commented 8 years ago

+1

juanpabloprado commented 8 years ago
@OnClick({ R.id.radio_pirates, R.id.radio_ninjas }) public void onRadioButtonClicked(RadioButton radioButton) {
    // Is the button now checked?
    boolean checked = radioButton.isChecked();

    // Check which radio button was clicked
    switch (radioButton.getId()) {
      case R.id.radio_pirates:
        if (checked) {
          // Pirates are the best
        }
        break;
      case R.id.radio_ninjas:
        if (checked) {
          // Ninjas rule
        }
        break;
    }
  }
sourabhrustagi commented 8 years ago

+1

sahilguptalive commented 8 years ago

+1

AzraelWarrior commented 8 years ago

+1

ghost commented 8 years ago

So this listener is available?Now that this issue is closed?

danielgomezrico commented 8 years ago

@manideepl but the issue is not closed...

jotaemepereira commented 8 years ago

+1

foxsent commented 8 years ago

+1

juanpabloprado commented 8 years ago

https://jakewharton.github.io/butterknife/javadoc/butterknife/OnCheckedChanged.html

pernilla commented 8 years ago

+1

JaredBanyard commented 8 years ago

+1

v-rodionov commented 8 years ago

+1

snaigle commented 7 years ago

+1

fernandomantoan commented 7 years ago

+1

StanleyKou commented 7 years ago

+1

khoatd92 commented 7 years ago

+1

xiaogu-space commented 7 years ago

+1

AndreiD commented 7 years ago

+2

khoatd92 commented 7 years ago

+1

mr746866 commented 7 years ago

+1

jimitpatel commented 7 years ago

+1

putrabangga commented 7 years ago

+1

ivamacio commented 7 years ago

+1

mariocaseres commented 7 years ago

+1

felipebonezi commented 7 years ago

+1

rajsuvariya commented 7 years ago

This works

@OnCheckedChanged({R.id.rbt_yes, R.id.rbt_no})
public void radioButtonCheckChanged(CompoundButton v, boolean b){
     // insert your code here
}
ceduliocezar commented 7 years ago

+1

lys-Ethan commented 7 years ago

@BindView(R.id.cb_msg) public CheckBox cbMsg; @BindView(R.id.cb_phone) public CheckBox cbPhone; @OnCheckedChanged() protected void onCheckedMode(CompoundButton compoundButton,boolean isChecked) { if (compoundButton==cbMsg){ mode = isChecked?mode+ BlackList.MODE_SMS_INTERCEPT:mode-BlackList.MODE_SMS_INTERCEPT; } if (compoundButton==cbPhone){ mode = isChecked?mode+BlackList.MODE_PHONE_INTERCEPT:mode-BlackList.MODE_PHONE_INTERCEPT; } } what the problem is? crashed message is com.android.internal.policy.impl.PhoneWindow$DecorView cannot be cast to android.widget.CompoundButton