PopWindow的实现功能
来源:互联网 发布:bfprt算法 编辑:程序博客网 时间:2024/05/12 01:25
public class Main extends Activity {PopupWindow popupWindow;Button showButton;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);showButton=(Button)findViewById(R.id.button);showButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {LinearLayout l=new LinearLayout(Main.this);l.setBackgroundColor(Color.GRAY); TextView textView=new TextView(Main.this); textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); textView.setText("删除"); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.WHITE); l.addView(textView); popupWindow=new PopupWindow(l, 180, LayoutParams.WRAP_CONTENT); popupWindow.setFocusable(true); //必须获得焦点 //pop窗口必须设置背景 后触摸pop窗口外部才能让pop窗口消失 popupWindow.setBackgroundDrawable(Main.this.getResources().getDrawable(android.R.color.transparent));// popupWindow.setOutsideTouchable(true); int[] location = new int[2]; showButton.getLocationOnScreen(location);//获取控件在整个屏幕中的坐标 //在控件的右边 //popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0]+v.getWidth(), location[1]); //在控件的左边 //popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0]-popupWindow.getWidth(), location[1]); //在控件的上方 //popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0], location[1]-popupWindow.getHeight()); popupWindow.showAsDropDown(showButton);textView.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {popupWindow.dismiss();}});}});} }
0 0
- PopWindow的实现功能
- popwindow动画效果的实现
- setAnimationStyle实现的popwindow…
- PopWindow实现
- Android简单PopWindow的实现方法。
- android的PopWindow实现下拉弹窗
- 自定义Dialog实现popwindow的效果
- 基于PopWindow+Listview实现弹窗选择的界面实现
- PopWindow实现自定义Menu
- popwindow实现下拉菜单
- android-PopWindow简单实现
- react-native实现popwindow
- setAnimationStyle实现的popwindow显示消失的动画效果
- setAnimationStyle实现的popwindow显示消失的动画效果
- 简单的popwindow实现某个模块下拉单效果
- Android的PopWindow动画实现底部滑出菜单
- 【Popwindow】自定义popwindow的底部间隙问题
- 我喜欢的popwindow
- 对象间通信Signal和Slot机制
- 一个国家工业化为什么那么难?
- 新办法绕过xss过滤-让xss来的更猛烈些吧
- latex中用hyperref和CJK生成中文书签
- 嵌入式Linux设备驱动开发之:按键驱动程序实例
- PopWindow的实现功能
- Servlet基础(二)
- sybase
- 后台报Error performing load command
- U-Boot启动过程完全分析(-)
- VirtualBox虚拟机下Fedora17与windows宿主机共享文件夹的设置
- fputc、putc、putchar
- flickr
- eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案