首页 > 代码库 > Momo自定义DialogFragment
Momo自定义DialogFragment
在Fragnment弹窗提示
XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" android:background="@drawable/bg_common_toast"> <ImageView android:id="@+id/loadingdialog_fiv_icon" android:layout_width="30dip" android:layout_height="30dip" android:src="@drawable/logo2" /> <TextView android:id="@+id/loadingdialog_htv_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:gravity="left|center" android:textColor="#004B7C" android:textSize="14sp" /></LinearLayout>
类库:
public class FlippingLoadingDialogF:DialogFragment { TextView textView1; private string textViewText = ""; private Android.Views.Animations.Animation mAnimation; public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Android 3.x+ still wants to show title: disable Dialog.Window.RequestFeature(WindowFeatures.NoTitle); // Create our view var view = inflater.Inflate(Resource.Layout.common_flipping_loading_diloag, container, true); // Handle dismiss button click textView1 = view.FindViewById<TextView>(Resource.Id.loadingdialog_htv_text); textView1.Text = textViewText; ImageView mFivIcon=view.FindViewById<ImageView>(Resource.Id.loadingdialog_fiv_icon); return view; } public void SetText(string str) { textViewText = str; } public override void OnResume() { // Auto size the dialog based on it‘s contents Dialog.Window.SetLayout(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); // Make sure there is no background behind our view Dialog.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent)); // Disable standard dialog styling/frame/theme: our custom view should create full UI SetStyle(DialogFragmentStyle.NoFrame, Android.Resource.Style.Theme); base.OnResume(); } protected override void Dispose(bool disposing) { base.Dispose(disposing); } }
引用:
FlippingLoadingDialogF dialog = new FlippingLoadingDialogF ();dialog.SetText ("数据加载中,请稍后...");dialog.Show (this.Activity.FragmentManager, "dialog");
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。