I have created a checkbox with text and set as invisible. Currently it is unchecked and I know the position of the checkbox as I have boxes above. I want the box to be checked and visible when I tap at the position ( invisible at the moment ).
I am not sure if this is possible or not as I could not find anything after hours of Googling.Sharing the codes below.
xml code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_diabetes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:fontFamily="@font/ubuntu_regular"
android:layout_weight="0.2"
android:text="@string/diabetes"
android:textColor="@color/textColorAsh"
android:textSize="16sp" />
<CheckBox
android:id="@+id/check_diabetes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/checkBoxStyle"
android:visibility="invisible" />
</LinearLayout>
Here is how I am try to make it visible programmatically. However it is not getting visible when I tap on the place where it is rendered.
case R.id.check_diabetes:
if (b == true) {
tv_diabetes.setTextColor(getResources().getColor(R.color.textColorBlue));
check_diabetes.setVisibility(View.VISIBLE);
diabetes = "1";
} else {...