android自定义dialog实现下拉弹出框效果
来源:互联网 发布:数据仿真模型 编辑:程序博客网 时间:2024/09/21 08:14
上一篇以activity方式实现了弹出框效果,这一篇就以dialog方式实现
直接看布局代码:
<?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="@drawable/xiyouhui_title_dialog_bg" > <ListView android:id="@+id/ls_hdyy_dialogleft" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="40dp" android:layout_marginBottom="10dp" android:divider="#ffffff" android:dividerHeight="1dp"></ListView></LinearLayout>
不过多说明,看实现代码:
private void showLeftDialog(){View view = LayoutInflater.from(this).inflate(R.layout.xyh_hdyy_dialogleft, null);WindowManager wm = this.getWindowManager();int width = wm.getDefaultDisplay().getWidth();//创建dialog实例,R.style.MyDialogStyleTop为样式,可以在其中加入动画效果,同上一篇activity的样式Dialog dialogLeft = new Dialog(this,R.style.MyDialogStyleTop);dialogLeft.setContentView(view);dialogLeft.setCanceledOnTouchOutside(true); Window dialogWindow = dialogLeft.getWindow(); WindowManager.LayoutParams lp = dialogWindow.getAttributes(); dialogWindow.setGravity(Gravity.LEFT | Gravity.TOP); lp.x = 0; // 新位置X坐标 lp.y = 110; // 新位置Y坐标 lp.width = (int) (width*0.5); // 宽度 lp.height = WindowManager.LayoutParams.WRAP_CONTENT; // 高度 dialogWindow.setAttributes(lp); listLeft.clear();
listLeft = getListData("ceoactivity");//list添加数据 listLeft.add("全部"); // ListView listViewDialogLeft = (ListView) view.findViewById(R.id.ls_hdyy_dialogleft); // YuYueDialogAdapter adapterleft = new YuYueDialogAdapter(XiyouhuiHuoDongYuYueActivity.this, listLeft); // listViewDialogLeft.setAdapter(adapterleft); // listViewDialogLeft.setOnItemClickListener(onItemClickListenerLeft); dialogLeft.show();}
没有采用继承Dialog类的方式实现,直接在要显示的activity中添加dialog,并为此dialog添加view,然后通过WindowManager,定义dialog的位置
- android自定义dialog实现下拉弹出框效果
- Android自定义Dialog实现弹出二维码效果
- android 自定义弹出框Dialog
- android自定义dialog弹出框
- 在Dialog中实现下拉框效果并对下拉框赋自定义的值
- android自定义弹出框实现方式(dialog)
- Android中Dialog实现自定义弹出对话框
- Android--自定义弹出框-自定义dialog
- android自定义dialog弹出框、透明背景
- Android Dialog 弹出框 自定义 样式
- android 自定义Dialog弹出提示框
- android 自定义Dialog.Builder弹出框
- Android自定义Dialog效果
- 自定义dialog弹出框
- 自定义dialog弹出框
- 自定义弹出框Dialog
- android dialog实现底部弹出和手指滑动隐藏效果
- 自定义Dialog 实现弹出窗口
- SVN服务器搭建和使用(二)
- JS获取浏览器窗口大小 获取屏幕,浏览器,网页高度宽度
- 随机数不随机呀——rand()与srand()
- いたずら学園 免DVD 重启破解+界面汉化补丁
- 让DIV一直固定在屏幕的某个位置
- android自定义dialog实现下拉弹出框效果
- win7/8 建立wifi热点
- Android开发者指南-创建状态栏通知(Status Bar)[原创译文]
- ++i和i++ (自己的理解)
- 广州传智播客PHP培训课程 给您最想要的新技术
- JAVA字符串占位符替换
- Struts2(多)文件上传和下载使用示例
- loop设备及losetup命令介绍
- 关于utf-8编码的ajax中url传中文及特殊符号乱码的实际可用处理办法