Hi Everyone,
I'm using the form-master library for my Android app. Everything in the form appears to work fine with the RecyclerView apart from the Switches in the app.
I'll click one switch and it will work just fine. When I move down and the elements are out of the view, when I go back to click on another switch, it will click the wrong one. I've heard this is a common issue, however, the code provided by this library looks like it should handle the position but does not.
Here is some of the code that handles the RecyclerView for the switch element.
Any help with this would be much appreciated. This is a lovely library to use and it's a shame not all of it can be used because of this issue.
I'm using the form-master library for my Android app. Everything in the form appears to work fine with the RecyclerView apart from the Switches in the app.
I'll click one switch and it will work just fine. When I move down and the elements are out of the view, when I go back to click on another switch, it will click the wrong one. I've heard this is a common issue, however, the code provided by this library looks like it should handle the position but does not.
Here is some of the code that handles the RecyclerView for the switch element.
Java:
public class FormElementSwitchViewHolder extends BaseViewHolder {
public AppCompatTextView mTextViewTitle, mTextViewPositive, mTextViewNegative;
public SwitchCompat mSwitch;
private ReloadListener mReloadListener;
private BaseFormElement mFormElement;
private FormElementSwitch mFormElementSwitch;
private int mPosition;
public FormElementSwitchViewHolder(View v, Context context, ReloadListener reloadListener) {
super(v);
mTextViewTitle = (AppCompatTextView) v.findViewById(R.id.formElementTitle);
mTextViewPositive = (AppCompatTextView) v.findViewById(R.id.formElementPositiveText);
mTextViewNegative = (AppCompatTextView) v.findViewById(R.id.formElementNegativeText);
mSwitch = (SwitchCompat) v.findViewById(R.id.formElementSwitch);
mReloadListener = reloadListener;
}
@Override
public void bind(final int position, BaseFormElement formElement, final Context context) {
mFormElement = formElement;
mPosition = position;
mFormElementSwitch = (FormElementSwitch) mFormElement;
mTextViewTitle.setText(mFormElementSwitch.getTitle());
mTextViewPositive.setText(mFormElementSwitch.getPositiveText());
mTextViewNegative.setHint(mFormElementSwitch.getNegativeText());
mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mReloadListener.updateValue(position, b ? mFormElementSwitch.getPositiveText() : mFormElementSwitch.getNegativeText());
}
});
}
Any help with this would be much appreciated. This is a lovely library to use and it's a shame not all of it can be used because of this issue.
