日期:2014-05-20 浏览次数:20806 次
import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.ImageView; public class MyDialog extends Dialog { Context context; public MyDialog(Context context) { super(context); // TODO Auto-generated constructor stub this.context = context; } public MyDialog(Context context, int theme){ super(context, theme); this.context = context; } @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); this.setContentView(R.layout.dialog); ImageView imageview = (ImageView)findViewById(R.id.imageviewClose); imageview.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismiss(); } }); } public void dismiss(){ this.cancel(); } }
08-17 15:32:42.080: E/AndroidRuntime(1326): FATAL EXCEPTION: main 08-17 15:32:42.080: E/AndroidRuntime(1326): java.lang.StackOverflowError 08-17 15:32:42.080: E/AndroidRuntime(1326): at com.xiuman.mydialog.MyDialog.dismiss(MyDialog.java:37) 08-17 15:32:42.080: E/AndroidRuntime(1326): at android.app.Dialog.cancel(Dialog.java:951) 08-17 15:32:42.080: E/AndroidRuntime(1326): at com.xiuman.mydialog.MyDialog.dismiss(MyDialog.java:37) 08-17 15:32:42.080: E/AndroidRuntime(1326): at android.app.Dialog.cancel(Dialog.java:951) 08-17 15:32:42.080: E/AndroidRuntime(1326): at com.xiuman.mydialog.MyDialog.dismiss(MyDialog.java:37) 08-17 15:32:42.080: E/AndroidRuntime(1326): at android.app.Dialog.cancel(Dialog.java:951) 08-17 15:32:42.080: E/AndroidRuntime(1326): at com.xiuman.mydialog.MyDialog.dismiss(MyDialog.java:37) 08-17 15:32:42.080: E/AndroidRuntime(1326): at android.app.Dialog.cancel(Dialog.java:951)