| 关键词: nbsp onClickListener Context view private LayoutInflater loadingDialog findViewById Button setOnClickListen |
[java] view plaincopypublic class DialogMenu { private Context mContext; private TextView tv_title, tv_context; private Button yes, no; private View view; private LayoutInflater layoutInflater; private Dialog loadingDialog; public DialogMenu(Context context) { this.mContext = context; this.layoutInflater = LayoutInflater.from(context); onCreateView(); } public void onCreateView() { view = layoutInflater.inflate(R.layout.dialog_popup, null); tv_title = (TextView) view.findViewById(R.id.textView1); tv_context = (TextView) view.findViewById(R.id.textView2); yes = (Button) view.findViewById(R.id.button2); no = (Button) view.findViewById(R.id.button1); loadingDialog = new Dialog(mContext, R.style.loading_dialog);// 创建自定义样式 } public void showDialog() { loadingDialog.show(); } public void initUI(String title, String msg, String tv_yes, String tv_no) { tv_title.setText(title); tv_context.setText(msg); no.setText(tv_no); yes.setText(tv_yes); if (onClickListener != null && onClickListener instanceof OnClickListener) { yes.setOnClickListener(onClickListener); no.setOnClickListener(onClickListener); } loadingDialog.setContentView(view); } private OnClickListener onClickListener; public void setOnClickListener(OnClickListener onClickListener) { this.onClickListener = onClickListener; } } [java] view plaincopy |