-1
我有一個應用程序,即有活性(稱爲MyFirstActivity)和的onCreate是這樣的:android如何在視圖中重新啓動我的活動?
MyView view;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game_sound_space);
RelativeLayout layout = (RelativeLayout) findViewById(R.id.myMain);
view = new MyView(this, getPreferences(Context.MODE_PRIVATE), layout);
layout.addView(view, 0); // add view to the layout
}
的觀點是這樣的(這是構造函數):
Context context;//I need to do context global for using in other methods
public MyView(Context context,SharedPreferences sharedPreferences,
RelativeLayout parentLayout) {
super(context);
this.context = context;
}
顯然在對方法的onResume活動,我開始認爲:
@Override
public void onResume(){
super.onResume();
view.loadGame();
}
的loadGame()是在我看來,它的作品完美,但在我v某些點IEW我要再次重新啓動,整場比賽,我已經使用:
,但我有懷疑,這是不是重新啓動的正確方法(和開始出問題) 也使用:
Intent intent = getIntent();
finish();
startActivity(intent);
其不可能的,因爲我在一個視圖和context.finish()不工作(不存在)
讓我怎麼重啓firstActivity(MyFirstActivity),以重新啓動的觀點,並與這場比賽?需要幫助,謝謝。