我有3個活動
-scelta
-checkin
-instarghe
充值活動後返回鍵
形式scelta和簽入我可以去instarghe。 我希望當我從checkin開始時,如果使用後退按鈕,checkin活動將會重新執行。
實施例:
籤 - > instarghe - >後退按鈕 - >我執行第二次籤
scelta - > instarghe - >後退按鈕 - >正常返回到scelta
我怎樣才能做?
我寫這篇文章的代碼:
protected void onRestart(){
//popolamento dello spinnero
String risposta=postTarghe();
Spinner spinner = (Spinner) findViewById(R.id.spnTarghe);
final String targhe[]=risposta.split("/");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_spinner_item,
targhe
);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View v, int position,long id) {
sTarga=targhe[position];
Log.d(TAG,"questa è la posizione selezionata: "+position);
Log.d(TAG,"questa è la targa: "+sTarga);
}
public void onNothingSelected(AdapterView<?> parentView) {
// your code here
}
});
};
但是當我嘗試,應用程序crashs。 這是logcat的:
了java.lang.RuntimeException:無法恢復活動{com.homelinux.agnese/com.homelinux.agnese.entrata}:android.app.SuperNotCalledException:活動{com.homelinux。 agnese/com.homelinux.agnese.entrata}沒有通過調用super.onRestart() 引起:android.app.SuperNotCalledException:活動{com.homelinux.agnese/com.homelinux.agnese.entrata}沒有通過調用到super.onRestart()
「登入活動將重新excecute」在onRestart不能執行只有必需的工作和更新用戶界面,而不是創建再次籤? –
這是好嗎?或者你有一些特殊要求重新檢查登陸 –