解决方案 »

  1.   

    注释掉dialog.show()就不会强制关闭了
      

  2.   

    问一下,你能确定 int [] used = game.getUsedTilesByCoor(x,y); 所获取的int数组一定是9个元素的吗?,你在Dialog中 声明了 private View keyButton[] = new View[9];
        private int[] usedData = new int[9];,是不是因为你接下来的语句中对keyButton遍历,导致两个数组没有对应上,出错了?
      

  3.   

     android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application。
    现在知道是什么原因了,问题不在上边的那两段代码上,在
    public class MainActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //setContentView(R.layout.main);
            setContentView(new MyView(getApplicationContext());
        }
    }
    把 setContentView(new MyView(getApplicationContext());改为setContentView(new MyView(MainActivity.this));就解决了