Android自定义Dialog问题

大致如下:

某个View中Ontouch事件

    Ontouch(){

    new XXDialog(this).show();

    //代码;

    Log.d("info","xxx");   

}

    我测试过了,两个都是在一个线程中的,但是为什么 new XXDialog(this).show();还没有运行完,也就是Dialog还没有出现,下面的代码就开始运行了,Log.d能打印出信息来。。

    有没有什么方法,让dialog里操作完成再开始运行下面的代码?

 

[code="java"]

Dialog是所有对话框的基类,但Dialog并非继承自View,而是直接从Object构造出来的。Dialog调用是异步调用,所以showDialog()时不会阻碍UI线程。

public class MyDialog extends Dialog implements DialogInterface{
DialogInterface listener。。。。
public void OnShowListener(){
Log.d("info","xxx");

}

public MyDialog(Context context, DialogInterface listener) {

super(context);

this.listener = listener;

}

}
[/code]

用回调函数
就是像类似这样的代码

[code="java"]new XXDialog(this).show(new Callback(){ callback(){
Log.d("info","xxx");

}});[/code]

也就是添加这个监听

[quote]public void setOnShowListener (DialogInterface.OnShowListener listener)

Since: API Level 8
Sets a listener to be invoked when the dialog is shown.
Parameters

listener The DialogInterface.OnShowListener to use.
[/quote]

代码类似这样

[code="java"] XXDialog xx = new XXDialog(this);
xx.setOnShowListener (new DialogInterface(){ public void OnShowListener(){
Log.d("info","xxx");

} });[/code]

[code="java"]晕 你是需要阻塞对话框
看下面连接·
http://blog.csdn.net/jilong17/article/details/7008533
[/code]