Please note that same code is working perfectly fine on Android Versions > KitKat
I have a dynamic view of questionnaire. All views are being added according to question coming up from the api I am using. What I am trying to do is, If question was required but user didn't filled it and trying to submit it, I am trying to setVisibility as 'VISIBLE' to my TextView having text "Required"
It works perfectly fine when I am either in Landscape or in Portrait mode, but right after changing the orientation, it stops working.
I have debugged the code and checked, status of visibility is being changed but UI is not being updated.
It is working fine other than KITKAT
I have tried view.invalidate(); as well.
TextView layout to be set as VISIBLE
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/required_prompt_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.goodsnitch.lib.ui.LatoRegularTextView
android:id="@+id/required_prompt_dynamic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/field_required_prompt"
android:textColor="@android:color/holo_red_light"
android:textSize="11dp"
android:textStyle="italic"
android:visibility="gone" />
</LinearLayout>
Java Code to make it visible
private void showRequiredPrompt(final View view) {
final TextView requiredLabel = (TextView) ((LinearLayout) view.getParent()).findViewById(R.id.required_prompt_dynamic);
if (requiredLabel != null) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
view.clearAnimation();
requiredLabel.clearAnimation();
requiredLabel.setVisibility(View.VISIBLE);
view.invalidate();
requiredLabel.invalidate();
}
}, 200);
}
}
I will appreciate your help :)
Editing question to explain further
This is code to show the label ON CLICK EVENT This is the toast showing visibility state of the label
Required label should appear just above first checkbox in RED color