0
我試圖設置自定義事件偵聽器,但該標誌沒有被觸發。下面是相關的代碼:設置自定義事件偵聽器
public interface onPlayerSetUpEventListener {
public void onPlayerSetUp();
}
private onPlayerSetUpEventListener mOnPlayerSetUpEventListener;
public void setOnPlayerSetUpEventListener(onPlayerSetUpEventListener eventListener) {
mOnPlayerSetUpEventListener = eventListener;
}
public void playerSetUp() {
if(mOnPlayerSetUpEventListener != null){
mOnPlayerSetUpEventListener.onPlayerSetUp();
}
}
/* The listener is set here */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initializeHotels();
FIRST_TURN = true;
super.onCreate(savedInstanceState);
clearOldBoard();
setContentView(R.layout.activity_game_board);
setUpBoardGUI();
setUpPlayers();
setOnPlayerSetUpEventListener(new onPlayerSetUpEventListener() {
@Override
public void onPlayerSetUp(){
prepForFirstTurn();
}
});
/* playerSetUp() should trigger the event */
public void setUpPlayers(){
<!-- Here we set up all the players and prep them for the start of game -->
playerSetUp();
}
我很新的事件處理這裏這麼一個額外的一雙眼睛幫我找出發生了什麼,爲什麼沒有得到執行事件將是巨大的!
是因爲它試圖處理onCreate()
內部的事件嗎?
感謝您提前幫忙!
JRad壞
哇。我覺得我好笨。大聲笑。謝謝。對那一個感到困惑。 –