我正在努力保存几个小时.恢复TextView和按钮.似乎我无法保存TextView,因为“outState”需要一个String.
我做了一个TicTacToe游戏,但是我希望在方向为“风景”时保存所有东西
这是我正在尝试做的一部分:
private Button lesBoutons[];
private Button rejouer;
private Jeu jeu;
private TextView leTexte;
private int[] tabGagne;
public boolean fini;
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.PutString("savText", leTexte);
//TextView savTexte = leTexte;
//String phrase=leTexte.toString();
//outState.putString("TEST", phrase);
//leTexte.getResources();
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// leTexte.setText(savedInstanceState.getString("TEST"));
}
如何保存此TextView和所有按钮?
解决方法:
做一个leTexte.getText().这将为您提供文本,但请确保首先初始化TextView对象.