public class MyDialog extends Dialog { private int FLAG_DISMISS = 1; private boolean flag = true; public MyDialog(Context context) { super(context); setTitle("自动消失对话框测试!"); }@Override public void show() { super.show(); mThread.start(); }@Override public void dismiss() { super.dismiss(); flag = false; }private Thread mThread = new Thread(){ @Override public void run() { super.run(); while(flag){ try { Thread.sleep(2000); Message msg = mHandler.obtainMessage(); msg.what = FLAG_DISMISS; mHandler.sendMessage(msg); } catch (InterruptedException e) { e.printStackTrace(); } } } }; private Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); if(msg.what == FLAG_DISMISS) dismiss(); } }; }LZ 筒子,AlertDialog都被框死用来做警告用的,不好操作。想实现自己的对话框还是继承Dialog然后DIY更好,选择也多得多了。我这个侍培雹自定义的Dialog就是显示了2s然后消失的中厅,测试过没问题。实现老帆起来也相当之简单,抛砖引玉,期待更好的方法。