עזרה באנדרואיד

userit8

New member
עזרה באנדרואיד

יש לי מחלקה של View בשם GameView ובאקטיבטי הראשי שלי אני שמה אותה כ ContentView בצורה הבאה


if(Const.gameView == null){
Const.gameView = new GameView(this);
Const.gameView.setViews(Const.chickenArr,Const.chickenViewArr,message,score_message , this.importantMessage , this.showTimerMessage);
setContentView(Const.gameView);

}


ברגע שיוצאים מהאקטיבטי וחוזרים אליו שוב, אני רוצה להציג כמובן שוב את הGameView וכאן אני נתקלת בבעיה.

כאשר אני משתמשת בקוד לעיל, בחזרה שנית לאקטיבטי לא מוצג לי ה GameView
וכאשר אני מוציאה את setContentView(Const.gameView מחוץ ל if האפלקיציה קורסת ובלוג יש לי את השגיאה:

11-10 22:17:35.821: E/AndroidRuntime(1580): Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

מה עושים?

תודה!
 
למעלה