It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center。
7年前关闭。
不管我改变了什么随机的东西,getint方法都带有下划线,然后如果我删除接收类的第一行,则将peepScore带下划线。错误
我会尽力弄清楚以后再添加,我想我最终会把这个即时贴发布给像我这样的所有newbs看到大声笑
当您使用getInt时,如果您的
共享首选项中未设置值。
7年前关闭。
SharedPreferences peepsScores= PreferenceManager.getDefaultSharedPreferences(GamePlayFirst.this);
SharedPreferences.Editor editor =peepsScores.edit();
editor.putInt("userScore1", zero);
editor.putInt("userScore2", zero);
editor.putInt("userScore3", zero);
editor.putInt("userScore4", zero);
editor.putInt("userScore5", zero);
editor.putInt("userScore6", zero);
editor.putInt("userScore7", zero);
editor.putInt("userScore8", zero);
editor.commit();
SharedPreferences peepsScores = PreferenceManager.getDefaultSharedPreferences(this);
//tryed this
int userScore1 = peepsScores.getInt("userScore1","u");
//tryed this
userScore2 = peepsScores.getInt("userScore2","0");
//and tryed this
String userScore3 = peepsScores.getInt("userScore3","0");
String userScore4 = peepsScores.getInt("userScore4","0");
String userScore5 = peepsScores.getInt("userScore5","0");
String userScore6 = peepsScores.getInt("userScore6","0");
String userScore7 = peepsScores.getInt("userScore7","0");
String userScore8 = peepsScores.getInt("userScore8","0");
不管我改变了什么随机的东西,getint方法都带有下划线,然后如果我删除接收类的第一行,则将peepScore带下划线。错误
我会尽力弄清楚以后再添加,我想我最终会把这个即时贴发布给像我这样的所有newbs看到大声笑
最佳答案
尝试这个。
int userScore1 = peepsScores.getInt("userScore1",0);
当您使用getInt时,如果您的
共享首选项中未设置值。
关于android - getInt()SharedPreferences android错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13138499/
10-12 05:10