New file |
| | |
| | | using System; |
| | | using Android.App; |
| | | using Android.Content; |
| | | using Android.Graphics; |
| | | using Android.Views; |
| | | using Android.Widget; |
| | | |
| | | namespace GateWay.Droid.FengLinVideo.widget |
| | | { |
| | | public class TipDiaglog : Dialog, View.IOnClickListener, View.IOnTouchListener |
| | | { |
| | | private Context mContext = null; |
| | | |
| | | private string titleText = "提示"; |
| | | private string contentText = ""; |
| | | private string confirmText = "确认"; |
| | | private bool isClose = false; |
| | | |
| | | private TextView contentView = null; |
| | | private TextView titleView = null; |
| | | private TextView okView = null; |
| | | public object Tag = null; |
| | | private OnConfirmClickListener onConfirmClickListener; |
| | | |
| | | public TipDiaglog(Context context) : base(context, Resource.Style.DialogTheme) |
| | | { |
| | | this.mContext = context; |
| | | } |
| | | |
| | | public void SetAutoClose(bool bol)
|
| | | { |
| | | this.isClose = bol; |
| | | } |
| | | |
| | | public void SetTitleText(string _titleText) |
| | | { |
| | | titleText = _titleText; |
| | | if (titleView != null) |
| | | { |
| | | titleView.SetText(titleText, null); |
| | | } |
| | | } |
| | | |
| | | public void SetContentText(string _contentText) |
| | | { |
| | | contentText = _contentText; |
| | | if (contentView != null) |
| | | { |
| | | contentView.SetText(contentText, null); |
| | | } |
| | | } |
| | | |
| | | public void SetConfirmText(string text) |
| | | { |
| | | confirmText = text; |
| | | if (okView != null) |
| | | { |
| | | okView.SetText(confirmText, null); |
| | | } |
| | | } |
| | | |
| | | public override void Create() |
| | | { |
| | | base.Create(); |
| | | |
| | | try |
| | | { |
| | | SetContentView(Resource.Layout.dialog_tip); |
| | | |
| | | contentView = (TextView)FindViewById(Resource.Id.tv_content); |
| | | titleView = (TextView)FindViewById(Resource.Id.tv_title); |
| | | okView = (TextView)FindViewById(Resource.Id.tv_ok); |
| | | |
| | | contentView.SetText(contentText, null); |
| | | titleView.SetText(titleText, null); |
| | | okView.SetText(confirmText, null); |
| | | |
| | | okView.SetOnTouchListener(this); |
| | | okView.SetOnClickListener(this); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | string error = e.Message; |
| | | } |
| | | } |
| | | |
| | | public override void OnWindowFocusChanged(bool hasFocus) |
| | | { |
| | | base.OnWindowFocusChanged(hasFocus); |
| | | |
| | | try |
| | | { |
| | | Display display = ((Activity)mContext).WindowManager.DefaultDisplay; |
| | | |
| | | WindowManagerLayoutParams p = Window.Attributes; |
| | | Point point = new Point(); |
| | | display.GetSize(point); |
| | | p.Width = (int)(point.X * 0.7); |
| | | Window.SetGravity(GravityFlags.Center); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | string ss = e.Message; |
| | | } |
| | | } |
| | | |
| | | public void SetConfirmClickListener(OnConfirmClickListener l) |
| | | { |
| | | onConfirmClickListener = l; |
| | | } |
| | | |
| | | public void OnClick(View v) |
| | | { |
| | | if (v.Equals(okView)) |
| | | { |
| | | if (onConfirmClickListener != null) |
| | | onConfirmClickListener.onSureClick(this, v, isClose); |
| | | } |
| | | } |
| | | |
| | | public bool OnTouch(View v, MotionEvent e) |
| | | { |
| | | if (e.Action == MotionEventActions.Down) |
| | | { |
| | | v.SetBackgroundResource(Resource.Drawable.sure_background_sel); |
| | | } |
| | | else if (e.Action == MotionEventActions.Up) |
| | | { |
| | | v.SetBackgroundResource(Resource.Drawable.sure_background_def); |
| | | } |
| | | |
| | | return false; |
| | | |
| | | } |
| | | |
| | | public interface OnConfirmClickListener |
| | | { |
| | | void onSureClick(TipDiaglog dialoog, View v,bool bol); |
| | | } |
| | | |
| | | } |
| | | } |