SurfaceView中弹出Dialog的实现

来源:互联网 发布:java md5加密 32位 编辑:程序博客网 时间:2024/05/22 16:47

需要在SurfaceView中弹出对话框,无法直接实现,避免是SurfaceView线程中修改UI。

折中的解决办法:在创建SurfaceView时会得到Context,使用其中的holder就可以弹出Dialog了。

备忘:

//自定义绘图方法
 public void   myDraw(){
  //game over
  if(player.live<=0){
   flag=false;
   context.hanlder.post(new Runnable(){
    public void run() {
     context.showDialog();
    }
   });
   return;
  }

原创粉丝点击