Showing preference screen first time app is run and related questions

后端 未结 4 1804
深忆病人
深忆病人 2021-02-06 08:34

I have an app with 2 activities, the preference and the main activity, I need the preference screen to show first time the app is run so the user can do some configuration. I ha

4条回答
  •  孤城傲影
    2021-02-06 09:07

    I've sorted this out with this bit of code in my main activity

    if (prefs.getString("edittextpref", null) == null)
        {
            startActivity(new Intent(this, Preferences.class));
            return;
        }
    
    }
    

    It just checks if one of your values is empty but you need to put this at the bottom of onCreate or else when you go back to the main page it will be blank.

提交回复
热议问题