我使用共享首選項來保存用戶頁碼。所以當用戶重新加載應用程序時,他們可以繼續閱讀他們離開的地方。他們的方式,我做了它的工作,但感覺凌亂,因爲這將結束像400如果和其他條件。有一個更好的方法嗎。許多thxAndroid對很多if和else條件
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (firstcheck.getText().toString().equals("")){
SavePrefs("FIRST_CHECK", firstcheck.getText().toString());
Intent myIntent = new Intent(SplashActivity.this, ConfigurationActivity.class);
startActivity(myIntent);
}else{
if (firstcheck.getText().toString().equals("0")){
Intent myIntent = new Intent(SplashActivity.this, BackgroundActivity.class);
startActivity(myIntent);
}else{
if (firstcheck.getText().toString().equals("1")){
Intent myIntent = new Intent(SplashActivity.this, Page1Activity.class);
startActivity(myIntent);
爲什麼在這裏要保存字符串值,而不是整數? –
我是java和android的新手,所以還有很多東西需要學習。猜它只是我遵循的教程,它似乎適用於我想要嘗試和做的事情。將考慮將其改爲一個整數,因爲這是有道理的。 thx –