I have a Checkbox
that sets a String
's value when the Checkbox
is checked or not checked. But my String
is returning a null value. I have declared the string inside the Public class
of the Activity
. Why is it returning null?
I want the strings to be inserted to a database FYI.
Lab = (CheckBox)findViewById(R.id.LabCheck);
Lec = (CheckBox)findViewById(R.id.RoomCheck);
Lab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
{
if(b)
{
LabText = "withlab";
}
else
{
LabText = "without";
}
}
});
Lec.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
{
if (b)
{
LecText = "corner";
}
else
{
LecText = "notcorner";
}
}
});
Toast toast2 = Toast.makeText(getApplicationContext(), LecText, Toast.LENGTH_SHORT);
toast2.show();
Toast toast2 = Toast.makeText(getApplicationContext(), LabText, Toast.LENGTH_SHORT);
toast2.show();
Aucun commentaire:
Enregistrer un commentaire