嗨,我正在制作一张显示 4 名玩家在游戏中得分的记分卡,当用户按下按钮时,将插入一个新行。我这样做:
private void makeTag(String P1Score, String P2Score, String P3Score, String P4Score, String slot)
{
// originalQuery will be null if we're modifying an existing search
String originalScore = SavedSlots.getString(slot, null);
// get a SharedPreferences.Editor to store new slot/scores
SharedPreferences.Editor preferencesEditor = SavedSlots.edit();
preferencesEditor.putString(slot, P1Score, P2Score, P3Score, P4Score); // to store
preferencesEditor.apply(); // store the updated preferences
然后它在说下提示错误putString
:
The method putString(String, String) in the type SharedPreferences.Editor is not
applicable for the arguments (String, String, String, String, String).
似乎一次只能存储2个变量?(即插槽和 P1Score)。
有 4 位玩家,我想保存他们各自的分数,我该怎么做?