Android中的PopupWindow的使用
PopupWindow 需要一个自定义的布局文件
列如:popupwindow.xml <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical" >
<TextView
android:textSize="25dp"
android:textColor="#ffffff"
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/start" /> <TextView
android:textSize="25dp"
android:textColor="#ffffff"
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/uninstall" /> <TextView
android:textSize="25dp"
android:textColor="#ffffff"
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/detil" /> </LinearLayout> LayoutInflater flater=LayoutInflater.from(context);
View popview=flater.inflate(R.layout.popuwindow, null);
PopupWindow popup=new PopupWindow(popview, 200, 130,true);
第一个参数:是自定义的布局文件
40 第二、三个参数:显示的宽、高
41 第四个参数:是否获得焦点
popup.showAsDropDown(view);显示在view(控件)的下面,
//创建一个自适应大小的弹出菜单
new PopupWindow(popview, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,true) //关闭popuwindow窗口
popup.dismiss(); 要想实现弹出的菜单的里面的菜单项的事件功能,就必须使用popview.findViewById(R.id.textview1)这样的方法之后才能为其添加事件监听器
Android中的PopupWindow的使用的更多相关文章
- android中使用PopupWindow实现弹出窗口菜单
结合上篇android中使用ViewPager实现图片拖动,我们实现了点击“帮助”按钮的功能,这一篇则是接着上一篇,让我们一起来完成“我的”按钮的功能,这一功能,则是使用PopupWindow来实现弹 ...
- Android中的PopupWindow
1.功能 PopupWindow这个类用来实现一个弹出框,可以使用任意布局的View作为其内容,这个弹出框是悬浮在当前activity之上的,可以设置显示位置. 2.需求 弹出软键盘,实现键盘功能从而 ...
- Android中的PopupWindow详解
Android的对话框有两种:PopupWindow和AlertDialog.它们的不同点在于: AlertDialog的位置固定,而PopupWindow的位置可以随意 AlertDialog是 ...
- Android 中PopupWindow使用 (转)
参考学习后遇到问题: 要引用:有好几个,可以用错误提示解决: import android.widget.PopupWindow; import android.widget.Toast; Activ ...
- Android中Popupwindow和Dialog的区别
Android中的对话框有两种:PopupWindow和AlertDialog.它们都可以实现弹窗功能,但是他们之间有一些差别,下面总结了一点. (1)Popupwindow在显示之前一定要设置宽高, ...
- Android开发之PopupWindow
/* * Android开发之PopupWindow * * Created on: 2011-8-8 * Author: blueeagle * Email: liujiaxiang@g ...
- Android 7.0 PopupWindow 的兼容问题
Android7.0 PopupWindow的兼容问题 Android7.0 中对 PopupWindow 这个常用的控件又做了一些改动,修复了以前遗留的一些问题的同时貌似又引入了一些问题,本文 ...
- Android中那些有你不知道的事
在安卓开发中,总有那么一些看似简单,实则绊脚的难题,等你去探索,等你去解决,也许你已经遇见了解决了,也许你还没碰上,写下这篇总结,希望能帮助那行即将遇到的朋友,快速解决这些小问题! 一.activit ...
- Android中相机和相冊使用分析
Android中相机和相冊使用分析 欢迎转载,但请尊重原创(文章来自不易,转载请标明转载出处,谢谢) 在手机应用程序中,使用自带的相机拍照以及相冊选择喜欢的图片是最常见只是的用户需求,那么怎么合理使用 ...
随机推荐
- IE的CSS相关的BUG(整理一)
本来不想弄这个ie的bug的,真的很想让它快点死掉,可是事与愿违啊,没办法,还是贴出来,以备自用. 这个网页(http://haslayout.net/css/index)上例举了所有的IE和CSS相 ...
- Cross-origin resource sharing--reference
Cross-origin resource sharing (CORS) is a mechanism that allows many resources (e.g., fonts, JavaScr ...
- 函数学习(JY07-JavaScript-JS基础03)
- 执行CMD命令
可以执行多条命令,用“\r\n”分割 using System; using System.Diagnostics; namespace Tool { public class CMDHelper { ...
- PHP输出中文乱码的问题(转)
用echo输出的中文显示成乱码, 其实应该是各种服务器脚本都会遇到这个问题, 根本还是编码问题, 一般来说出于编码兼容考虑大多的页面都将页面字符集定义为utf-8 <meta http-equi ...
- (转)jquery的html,text,val
.html()用为读取和修改元素的HTML标签 .text()用来读取或修改元素的纯文本内容 .val()用来读取或修改表单元素的value值. 这三个方法功能上的对比 .html(),.text() ...
- 关于.NET中的验证码
常用的生成验证码程序 ,图片效果如下: 源程序如下: 复制代码 代码如下:using System; using System.IO; using System.Drawing; using Syst ...
- .net面试总结
一. hr 为人处事 工作中遇到问题:沟通很重要 离职原因:公司倒闭 二. ISAPI Internet Server Application Program Interface 三. http状态码 ...
- MyEclipse内存不足的问题
今早打开MyEclipse莫名其妙弹出提示框,然后我各种搜索,用了网上能查到的各种办法去试图解决问题,方法包括但不限于 修改eclipse.ini .设置Default VM Arguments . ...
- 武汉科技大学ACM:1010: 零起点学算法89——母牛的故事
Problem Description 有一头母牛,它每年年初生一头小母牛.每头小母牛从第四个年头开始,每年年初也生一头小母牛.请编程实现在第n年的时候,共有多少头母牛? Input 输入数据由多个测 ...