12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package com.yyrh.ui.dialog;
- import android.app.Dialog;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.TextView;
- import com.yyrh.utils.ResourceUtil;
- public class SingleButtonDialog extends Dialog {
- private static TextView bt_exit_game,content;
- private static SingleButtonDialog dialog;
- public SingleButtonDialog(Context context, int theme) {
- super(context, theme);
- }
- public static class Builder{
- private Context context;
- private OnClickListener positiveButtonClickListener;
- public Builder(Context context){ this.context = context;}
- public Builder setPositiveButton(OnClickListener listener){
- this.positiveButtonClickListener = listener;
- return this;
- }
- public void dialogDismiss(){dialog.dismiss();}
- public SingleButtonDialog Create(String msg){
- {
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- dialog = new SingleButtonDialog(context,ResourceUtil.getStyleId(context,"qj_base_dialog"));
- View layout;
- layout = inflater.inflate(ResourceUtil.getLayoutId(context, "qj_ios_style_dialog"),null);
- dialog.addContentView(layout,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- bt_exit_game =(TextView) dialog.findViewById(ResourceUtil.getId(context,
- "confirm"));
- content =(TextView) dialog.findViewById(ResourceUtil.getId(context,
- "content"));
- content.setText(msg);
- if (bt_exit_game!=null){
- bt_exit_game.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- positiveButtonClickListener.onClick(dialog,DialogInterface.BUTTON_POSITIVE);
- }
- });
- }
- }
- return dialog;
- }
- }
- }
|