zoukankan      html  css  js  c++  java
  • Android popupwindow

        final Button popup = (Button) findViewById(R.id.button1);      //popupwindow JAVA代码部分 
            popup.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    View view = LayoutInflater.from(getApplication()).inflate(R.layout.popuplayout, null);
                    final PopupWindow popupWindow = new PopupWindow(view,      //三个属性,视图,高和宽
                            ViewGroup.LayoutParams.WRAP_CONTENT,
                            ViewGroup.LayoutParams.WRAP_CONTENT);
                    popupWindow.setFocusable(true);                      //必须获取焦点True,否则其他能继续操作就无意义了
                    popupWindow.showAsDropDown(popup);                    //设置弹出的位置
                    ImageView imageView = (ImageView) view.findViewById(R.id.img);
                    imageView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            popupWindow.dismiss();
                        }
                    });
                }
            });

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.zhuoxiang.enlightnment.Activity.PopupActivity">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/img"
            android:src="@drawable/delete"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/text"
            android:text="删除"
            android:layout_toRightOf="@+id/img"/>
    </RelativeLayout>
    
    
    
     
  • 相关阅读:
    ASP.NET 缓存技术分析
    asp.net中两款文本编辑器NicEdit和Kindeditor
    VS2005,VS2008,VS2010将ASP.NET网站编译成一个DLL文件
    公共的Json操作C#类
    怎么把100多个EXCEL文件合并成一个
    C# ToString()方法一些特殊用法
    C# 将数据导出到Execl汇总
    ASP.NET MVC中在Action获取提交的表单数据方法总结
    vue实现锚点定位跳转(当前页面跳转,url不变)
    es6 去除小数点后,不四舍五入
  • 原文地址:https://www.cnblogs.com/infernofranz/p/5847343.html
Copyright © 2011-2022 走看看