package com.fxy.progressdialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.fxy.R;
public class CustomDialog {

    private Context context;
    Dialog dialog;
    public CustomDialog(Context context){
        this.context = context;
        dialog = new Dialog(context);
    }
    public void show(){
        View view = LayoutInflater.from(context).inflate(R.layout.custom_dialog, null);
        //inflate的第二个参数为null表示当前对话框的布局没根布局
        dialog.setContentView(view);
        /*
         * setContentView(R.layout.custom_dialog);
         * 也可以以这种方式加载
         */
        dialog.setTitle("自定义的对话框");
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView1);
        imageView.setImageResource(R.drawable.ic_launcher);
        TextView textView = (TextView) view.findViewById(R.id.textView1);
        textView.setText("这是自定义对话框");
        dialog.show();
    }
}
