AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this); 
搞不清楚MainDialog.this这个是个什么对象,有的是
AlertDialog.Builder builder = new AlertDialog.Builder(this); 
只要一创建builder对象,虚拟设备中就提示:
The application Test2New(process com.zh2)has stopped unexpectedly.please try again;
什么突发事件停止,

解决方案 »

  1.   

    Builder构造器的参数this,指的是Context这个类,可以理解成一个“上下文环境”。楼主可以看看官方的API文档。
      

  2.   

    那正确的警告对话框对象声明应该是?为什么编译通过,但是报The application Test2New(process com.zh2)has stopped unexpectedly.please try again;
    警告提示
      

  3.   

    匿名类?我做。net的,刚开始也搞不懂这个概念。
    LZ只要记住,如果在匿名类的方法中要调用上一层的对象,就用对象.this.XXX
      

  4.   

    不是这个意思,那个参数我明白,我的问题是,编译通过后,在虚拟设备执行的时候报这个错误是什么原因,就弹出一个对话框而已:The application Test2New(process com.zh2)has stopped unexpectedly.please try again;
      

  5.   


    AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this); 
    //MainDialog是当前类名称;MainDialog.this理解成一个“上下文环境”
    //你可以把AlertDialog.Builder builder = new AlertDialog.Builder(this);  中的this换成MainDialog.this
      

  6.   

    AlertDialog.Builder builder = new AlertDialog.Builder(Test2NewActivity.this); 
    Test2NewActivity这个是我的类,我改了,编译通过了,但是还是提示The application Test2New(process com.zh2)has stopped unexpectedly.please try again;
    想自杀了,抓狂中......
      

  7.   

    搞定了,对象声明的位置,我xxxxxooooooo的