I am trying to check whether the radio button is checked or not. On basis of that, I will trigger some actions. I searched and found out "isChecked" is the method to do so. I use that method but the android studio says Cannot Resolve symbol 'isChecked()'.
<CheckBox
android:id="@+id/cream"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:checked="false"
android:paddingLeft="26dp"
android:text="Whipped Cream"
android:textSize="16sp" />
final CheckBox box = (CheckBox) findViewById(R.id.cream);
if (box.isChecked())
{
box.setChecked(false);
}
Thank you in advance.
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
Having a similar problem now, with v
final CheckBox whipped_cream_variable = (CheckBox) findViewById(R.id.whipped_cream);
boolean whipped_cream_has = whipped_cream_variable.isChecked();
Log.v("MainActivity", "Has whipped cream:" + whipped_cream_has);
Dan Baruch solved the problem