Android自定义个性化的Dialog示例
本文实例讲述了Android自定义个性化的Dialog。分享给大家供大家参考,具体如下:
Dialog:
mDialog = new Dialog(this, R.style.chooseUserDialogTheme); mDialog.setTitle(R.string.choose_user); View rootView = LayoutInflater.from(this).inflate( R.layout.view_simple_choose_user, null); mDialog.setContentView(rootView); mLinearLayoutUserList = (LinearLayout) rootView .findViewById(R.id.linearLayout_user_list); mDialog.show(); mIsUserListShown = true; DialogInterface.OnDismissListener listener = new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { timer.cancel(); mIsUserListShown = false; } }; mDialog.setOnDismissListener(listener);
R.style.chooseUserDialog
<style name="chooseUserDialogTheme" parent="@android:style/Theme.Dialog"> <item name="android:background">@android:color/transparent</item> <item name="android:textAppearance">@style/textAppearanceL</item> <item name="android:textColor">@android:color/white</item> <item name="android:windowBackground">@drawable/bg_choose_user_simple</item> <item name="android:popupBackground">@drawable/bg_main_activity_top_bar</item> </style>
R.layout.view_simple_choose_user
<?xml version="1.0" encoding="utf-8"?> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_main_activity_top_bar" android:orientation="vertical" > <LinearLayout android:id="@+id/linearLayout_user_list" android:layout_width="0dp" android:layout_height="wrap_content" android:orientation="horizontal" > </LinearLayout> </HorizontalScrollView>
更多关于Android相关内容感兴趣的读者可查看本站专题:《Android开发入门与进阶教程》、《Android调试技巧与常见问题解决方法汇总》、《Android多媒体操作技巧汇总(音频,视频,录音等)》、《Android基本组件用法总结》、《Android视图View技巧总结》、《Android布局layout技巧总结》及《Android控件用法总结》
希望本文所述对大家Android程序设计有所帮助。
赞 (0)