This is not a problem, but I'm trying to find the right way to do this.
I have the following situation:
public class SettingsDialogFragment extends DialogFragment implements OnCheckedChangeListener { ... @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.settings, container); ... CheckBox lBox1 = (CheckBox)view.findViewById(R.id.checkBox1); lBox1.setOnCheckedChangeListener(this); lBox1.setChecked(true); return view; } @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { .... }
My "problem" is that by calling setChecked(true) , onCheckChanged is already firing. I assume that when I inflate the layout, the CheckBox initialized with a false parameter, and I change it to true, this is the CheckedChanged event.
I could, of course, reorder and assign a listener after I set the initial value, but is there a way to inflate the layout by somehow passing the initial values ββto the different components? They are dynamic, so I canβt fix the values ββto a specific value in settings.xml
Greetings
source share