StefanD
StefanD

Reputation: 7

Android Studio onCheckedChanged method

In Android Studio 4.0, when it creates the onCheckedChanged method for a checkbox's setOnCheckedChangedListener it's 2 parameters are Compound Button buttonView, boolean b, how do I change Android Studio default to name this particular variable isChecked like I see everyone else has, and obviously makes more sense?

from:

public void onCheckedChanged(CompoundButton compoundButton, boolean b)

to:

public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked)

I do it manually but it's frustrating, so is there a way around this? I also looked in preferences but haven't found anything.

Thank you.

PS: First question here :)

Upvotes: 0

Views: 465

Answers (1)

einUsername
einUsername

Reputation: 1619

I don't think that's possible. It's just the name someone who worked on Android gave that variable.

When you let Android Studio create that method automatically it will name the parameters like they are named in the interface. How would Android Studio know what name you prefer? But is this really such a big hassle? ;-)

Of course you could always use Edit > Find > Replace if you have many Listeners.

Upvotes: 1

Related Questions