获取 - 无法解析符号" putString" " putInt" "提交" - 在下面的代码中。请帮助。
public class Alpha extends Activity {
public static final String GAME_PREFERENCES = "GamePrefs";
SharedPreferences settings =getSharedPreferences(GAME_PREFERENCES,MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settings.edit();
prefEditor.putString("Gama x","Blue Spec");
prefEditor.putInt("Wave",292);
prefEditor.commit();
}
答案 0 :(得分:0)
在开始随机编码之前,请看一些Android教程,例如我认为this is the best 。
您可以从编码开始。
顺便说一句,解决方案是在“onCreate”方法中移动它:
public class Alpha extends Activity {
public static final String GAME_PREFERENCES = "GamePrefs";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SharedPreferences settings =getSharedPreferences(GAME_PREFERENCES,MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settings.edit();
prefEditor.putString("Gama x","Blue Spec");
prefEditor.putInt("Wave",292);
prefEditor.commit();
}
}