0
I need that when I click on a Switch Button, the Mainactivity.kt is replaced by another Activity called Activitydois.java and that the option is maintained. And only if the user clicks the Switch Button again, the original Mainactivity.kt is restored.
Question: How to exchange Mainactivty for another class and maintain this option even by restarting the app?
Mainactivity.kt
class Mainactivity : Appcompatactivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
Activitydois.java
public class ActivityDois extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dois);
}
Good morning buddy, you just have to save the state of Activity. Follow link that will help you a lot. How to save
– Gabriel Cavalcante