I have a checkbox, defined as such in XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFF">
<CheckBox
android:id="@+id/checkbox_monitor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Monitor (present and restocked)"
android:layout_centerHorizontal="true"
android:layout_marginTop="6dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="6dp"/>
</RelativeLayout>
...
</LinearLayout>
This LinearLayout is made up of ten similar RelativeLayouts and is embedded within a ScrollView, if that makes any difference.
Here is the corresponding Activity
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_eos);
setTitle("End of Shift Check-Off");
setToolbarColor();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Checkboxes
CheckBox cbMonitor = findViewById(R.id.checkbox_monitor);
cbMonitor.setChecked(true);
....
}
Simply put, the setChecked()
function does not work. Initially, I assumed my condition was not returning true, but the function on its own does not work and I have no idea why. I have been searching for hours, any help or feedback at all is greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire