AlertDialog中使用自定义View中的点击监听如何实现

public void showDialog(Context mContext) {  
        LayoutInflater inflater = LayoutInflater.from(mContext); 
        View view = inflater.inflate(R.layout.test, null); 

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 
        builder.setTitle(R.string.test); 
        builder.setView(view); 
        builder.create(); 

        Button bt_test = (Button) view.findViewById(R.id.test); 
        bt_test.setOnClickListener(new android.view.View.OnClickListener(){  

            @Override  
            public void onClick(View v) {  
                Log.i("测试", "对话框中的Button被点击了"); 
            }  
        }); 

        builder.show(); 
    }  

你可能感兴趣的:(dialog)