0
這裏的問題是,什麼與它去:安全動態創建的視圖,當應用程序被殺害
的應用: 我的小應用程序,可以讓一些文本的用戶TIPE到EDITTEXT和的onClick他可以在下面的linearLayout中將其顯示爲帶有文本的複選框。
初始狀態: 我保存使用的onSaveInstanceState()中的變量 - 和onRestoreInstanceState()方法和它完美的作品時,只是方向的變化,但如果應用程序變得辭去和全新開業...
問題: 如何安全checkBoxes/LinealLayout,以便每次用戶關閉並重新打開應用程序時,列表不會重置?
的Java代碼:
public class MainActivity extends AppCompatActivity {
int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android");
int i;
public CheckBox[] checkBox;
public CheckBox[] checker;
public String speicher;
public String bringer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
layout = (LinearLayout) findViewById(R.id.layout);
button = (ImageButton) findViewById(R.id.button);
button.setId(R.id.id);
editText = (EditText) findViewById(R.id.editText);
clear = (ImageButton) findViewById(R.id.delete);
parent = (RelativeLayout) findViewById(R.id.parent);
scroller = (ScrollView) findViewById(R.id.scroller);
}
public void deleteAllBoxes() {
Toast.makeText(getBaseContext(), "List cleared", Toast.LENGTH_SHORT).show();
layout.removeAllViews();
editText.setText("");
checkBox = null;
checker = null;
content.clear();
brücke.clear();
speicher = null;
bringer = null;
i = 0;
}
}
的應用:
隨時可以使用其中一個android存儲選項 – Selvin