我想在表面视图中使用输入对话框在Android游戏结束时取名为Player

时间:2016-04-03 16:12:37

标签: java android android-studio

我想加载播放器的详细信息以及数据库中的高分

以下代码来自SurfaceView类。在达到endthegame()方法后,它能够重复打印输出,其余的代码没有到达

 04-03 21:34:55.580 7817-8355/androidmydream.myfirstgame I/System.out: REACHED BUILDER DIALOG BOX START
04-03 21:34:55.580 7817-8355/androidmydream.myfirstgame I/System.out: THIS IS A TEST FOR BUILDER 0
04-03 21:34:55.581 7817-8355/androidmydream.myfirstgame I/System.out: THIS IS A TEST FOR BUILDER 1
04-03 21:34:55.659 7817-8355/androidmydream.myfirstgame I/System.out: REACHED BUILDER DIALOG BOX START
04-03 21:34:55.659 7817-8355/androidmydream.myfirstgame I/System.out: THIS IS A TEST FOR BUILDER 0
04-03 21:34:55.659 7817-8355/androidmydream.myfirstgame I/System.out: THIS IS A TEST FOR BUILDER 1
04-03 21:34:55.696 7817-8355/androidmydream.myfirstgame I/System.out: REACHED BUILDER DIALOG BOX START
04-03 21:34:55.696 7817-8355/androidmydream.myfirstgame I/System.out: THIS IS A TEST FOR BUILDER 0
04-03 21:34:55.696 7817-8355/androidmydream.myfirstgame I/System.out: THIS IS A TEST FOR BUILDER 1

游戏没有停止,我在Log中没有错误。我不明白发生了什么。

    public class GamePanel extends SurfaceView implements SurfaceHolder.Callback
    {
    .....    
    public void endthegame()
            {
                System.out.println("REACHED BUILDER DIALOG BOX START");
                if(GamePanel.isGameOver==true) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(context);
                    builder.setTitle("THIS IS A TEST for BUILDER");
                    LayoutInflater inflater = (LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
                    View view = inflater.inflate(R.layout.prompts, null);
                    builder.setView(view);
                    builder.setTitle("THIS IS A TEST for BUILDER 1");
                    View closeButton =view.findViewById(R.id.close);

                    builder.setTitle("THIS IS A TEST for BUILDER 2");
                    closeButton.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View clicked) {
                            if (clicked.getId() == R.id.close) {
                                ((Activity) getContext()).finish();
                            }
                        }
                    });
                    builder.setTitle("THIS IS A TEST for BUILDER 3");
                    AlertDialog finishDialog = builder.create();
                    finishDialog.show();
                    builder.setTitle("THIS IS A TEST for BUILDER 4");
                }
                System.out.println("REACHED BUILDER DIALOG BOX STOP");
                this.isGameOver=true;
            }
}

进入细节,游戏引擎在游戏线程中有更新和绘制方法。到达LayoutInflater方法后,该方法会自动停止,不会给出任何错误。

由于它是一个Thread,方法更新和绘制方法不断调用。

任何人都可以告诉我为什么LayoutInflater方法没有调用,并想知道为什么没有错误进入日志

0 个答案:

没有答案