Reputation: 4388
and I want to restrict the user from changing it. I should be able to change it programmatically but not by the user. I have tried, editable, clickable out did not work.
How should it be done?
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:paddingLeft="8dip"
android:paddingRight="8dip">
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/flight_origin_date"
style="@style/InputCheckBox"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="@string/new_order_flight_origin_date"
android:visibility="visible"
android:layout_weight="1"
android:layout_marginBottom="0dp"
app:buttonTint="@color/i6_teal" />
</LinearLayout>
Upvotes: 1
Views: 593
Reputation: 374
You can simply use an ImageView instead of checkbox, with two different sources, the first image will be a non-checked checkbox image and the second would be a checked-checkbox image, based on your state you can show either, as in if you want to programmatically check the check-box, just switch to the checked-checkbox image and vice-versa, similarly you can update the variables inside by simply switching image sources.
Upvotes: 0
Reputation: 2790
Please set following two fields to false
in androidx.appcompat.widget.AppCompatCheckBox
android:clickable="false"
android:focusable="false"
Upvotes: 1