介绍过AlertDialog之后,接下来就介绍一下PopupWindow这种对话框。PopupWindow是阻塞对话框,只有在外部线程 或者 PopupWindow本身做退出操作才行。PopupWindow完全依赖Layout做外观,在常见的开发中,PopupWindow应该会与AlertDialog常混用。
贴出本例中运行的结果图:
main.xml的源码如下:
view plaincopy to clipboardprint?
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <Button android:id="@+id/Button01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="PopupWindow演示"></Button>
- </LinearLayout>
下图是PopupWindow弹出的截图,这里的PopupWindow是个登录框,点“确定”则自动填写,点“取消”则关闭PopupWindow。
popupwindow.xml的源码:
view plaincopy to clipboardprint?
- <?xml version="1.0" encoding="utf-8"?>
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:orientation="vertical" android:background="#000000">
-
- <TextView android:id="@+id/username_view"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:layout_marginRight="20dip" android:text="用户名"
- android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="fill_parent"/>
-
- <EditText android:id="@+id/username_edit"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent" android:layout_marginLeft="20dip"
- android:layout_marginRight="20dip" android:capitalize="none"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <TextView android:id="@+id/password_view"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:layout_marginRight="20dip" android:text="密码"
- android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="fill_parent"/>
-
- <EditText android:id="@+id/password_edit"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent" android:layout_marginLeft="20dip"
- android:layout_marginRight="20dip" android:capitalize="none"
- android:password="true"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <LinearLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center"><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/BtnOK" android:layout_weight="100" android:text="确定"></Button><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="100" android:text="取消" android:id="@+id/BtnCancel"></Button
分享到:
相关推荐
Android入门第十篇之PopupWindow.docx
介绍过AlertDialog之后,接下来就介绍一下PopupWindow这种对话框。PopupWindow是阻塞对话框,只有在外部线程或者PopupWindow本身做退出操作才行。PopupWindow完全依赖Layout做外观,在常见的开发中,PopupWindow应该...
Android从屏幕底部滑动弹出PopupWindow,有动画效果,类似于sharesdk的分享页面滑动弹出效果。
Android开发之PopupWindow实现弹窗
Android弹窗实现之Popupwindow及DialogFragment。创建并实现PopupWindow布局 实现PopupWindow对象实例 设置PopupWindow背景、动画属性、控件实现及事件监听 显示PopupWindow及位置设定。
Android自定义下拉框,用PopupWindow实现
android 封装一个通用PopupWindow,避免重复造轮子,简化代码,方便管理。
安卓Android源码——Android之用PopupWindow实现弹出菜单.zip
Android项目实现半透明的popupwindow.rar
android popupwindow 底部灰色背景
Android PopupWindow与Activity之间的数据传递
Android TV 开发有关PopupWindow的KeyListener
PopupWindow的简单使用!
安卓Android源码——精典源码之多级PopupWindow的小demo.zip
AS写的PopupWindow demo blog:http://blog.csdn.net/shenyuanqing/article/details/48136639
Android 单击listview弹出popupwindow弹出框,里面还附带listview右滑删除按钮。博客网址:http://blog.csdn.net/qq_16064871
大家可自行学习,研究,并补充该demo.
具体使用请关注博客:http://blog.csdn.net/stoppig 查看《Android中popWindow弹出菜单的编写》这篇文章
Android之用PopupWindow实现弹出listview形式菜单.rar
Android PopupWindow实例 Android PopupWindowAndroid PopupWindowAndroid PopupWindow