如题,怎样让程序在执行都某个地方,比如,当程序运行时间超过给定时间的时候,自动弹出时间到对话框?

解决方案 »

  1.   


    我的代码:
    1113 AlertDialog dialog;
    1114 dialog = builder.create();
    调试信息:
    11-26 11:22:09.689: E/AndroidRuntime(5686):  at aliao.wb.MySurfaceView.DialogPass(MySurfaceView.java:1114)
      

  2.   

    public void DialogPass() {
    AlertDialog.Builder builder = null;
    builder = new AlertDialog.Builder(this.getContext());
    // 实例化Builder对象
    builder = new AlertDialog.Builder(this.getContext());
    LayoutInflater factory = LayoutInflater.from(this.getContext());
    View textEntryView = factory.inflate(R.layout.passdialog, null);
    builder.setView(textEntryView); // 绑定
    ibtnRetry = (ImageButton) textEntryView.findViewById(R.id.btnRetry);
    ibtnRetry.setOnTouchListener(new OnTouchListener() { @Override
    public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN)
    ibtnRetry.setBackgroundDrawable(getResources()
    .getDrawable(R.drawable.retry_pressed));
    else if (event.getAction() == MotionEvent.ACTION_UP)
    ibtnRetry.setBackgroundDrawable(getResources()
    .getDrawable(R.drawable.retry));
    return false;
    }
    });

    // 显示对话框
    AlertDialog dialog = null;
    dialog = builder.create();
    System.out.println("dialog creat sussessed!");
    dialog.show();
    builder = null;
    //builder.create().show();
    }