dimanche 25 décembre 2016

Get a checkbox variable from another activity in Android

I'm a beginner in Android and Android Studio development and I really need help getting a checkbox's state. So basically I want to get if a checkbox from an activity is checked then if it is, show some text on the main activity. I've read lots and lots of SO Q&As but nothing worked. I got this:

CheckBox show = (CheckBox) findViewById(R.id.checkBox);

public CheckBox getShow() {
    return show;
}

So I'd use

CheckBox setty = Settings.getCheck();

on the other class. But I get an error:

Cannot resolve method 'getCheck()'

How can I do this? I need to get if it's on or off and display it on the main activity. Remember that I can't use Intents because I won't have a button to transition, the text and value must be always there on the main class.

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire