想要弹出内容就可以考虑使用悬浮窗

布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/rl_root"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".LoginActivity" ><com.handmark.pulltorefresh.library.PullToRefreshListViewandroid:id="@+id/lv_list"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:background="#fff" /><Viewandroid:id="@+id/viewHolder"android:layout_width="match_parent"android:layout_height="53dp"android:visibility="gone" />
</LinearLayout>

 代码

   lv_list.setOnItemLongClickListener(new OnItemLongClickListener() {@Overridepublic boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {Toast.makeText(getApplicationContext(), "长按", 0).show();//开启编辑模式startEditModel();if (position > 0) {position -= 1;}adapter.toggleSelect(view, position);return true;}});}private boolean isEditModel;private int seletedCount;/*** 开启编辑模式*/private void startEditModel() {//listview需要刷新isEditModel = true;adapter.notifyDataSetChanged();//修改actionbaruploadMenuItem.setVisible(false);downloadMenuItem.setVisible(false);moreMenuItem.setVisible(false);selectMenuItem.setVisible(true);actionBar.setDisplayHomeAsUpEnabled(true);actionBar.setTitle(String.format("已选定%d个", seletedCount));//显示底部的popupwindows
//当在最 底部时会覆盖条目,可以在下面弄个view,让他显示showBottomPopupWindow();//listview上移viewHolder.setVisibility(0);}/*** 结束编辑模式*/private void stopEditModel() {//listview需要刷新isEditModel = false;adapter.notifyDataSetChanged();//修改actionbaruploadMenuItem.setVisible(true);downloadMenuItem.setVisible(true);moreMenuItem.setVisible(true);selectMenuItem.setVisible(false);actionBar.setTitle("黑马网盘");//返回按钮的处理if ("/".equals(curPath)) {actionBar.setDisplayHomeAsUpEnabled(false);}//隐藏popupwindowsbottomPopupWindow.dismiss();//listview还原viewHolder.setVisibility(8);//还原entryWrapper的选中状态for (EntryWrapper entryWrapper : contents) {entryWrapper.isCheck = false;}seletedCount = 0;}private void showBottomPopupWindow() {if (bottomPopupWindow == null) {View contentView = View.inflate(MainActivity.this, R.layout.bottom_edit_pop, null);int width = ViewGroup.LayoutParams.FILL_PARENT;int height = ViewGroup.LayoutParams.WRAP_CONTENT;bottomPopupWindow = new PopupWindow(contentView, width, height);contentView.findViewById(R.id.DeleteBtn).setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {List<EntryWrapper> selectedEntryWrappers = new ArrayList<EntryWrapper>();for (EntryWrapper info : contents) {if (info.isCheck) {selectedEntryWrappers.add(info);}}StringBuffer sb = new StringBuffer();//遍历输出for (EntryWrapper entryWrapper : selectedEntryWrappers) {sb.append(entryWrapper.entry.fileName()).append(" ");}System.out.println(sb.toString());}});}bottomPopupWindow.showAtLocation(rl_root, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);}

  

转载于:https://www.cnblogs.com/sixrain/p/5276612.html

PopupWindow的使用相关推荐

  1. android 封装的popwindow,Android UI开发 popupwindow介绍以及代码实例

    PopupWindow在android.widget包下,弹出窗口的形式展示.官方文档对该控件的描述是:"一个弹出窗口控件,可以用来显示任意视图(View),而且会浮动在当前 活动(acti ...

  2. android window 大小,android popupWindow 中宽度莫名很大,求帮助?

    这个是popupwindow的内容xml(就是放了个ListView): android:layout_width="wrap_content" android:layout_he ...

  3. PopupWindow响应返回键的问题

    假设情景是这样的:在一个Activity中弹出一个PopupWindow,要求在按返回键时关闭该PopupWindow. 如果该PopupWindow是无焦点的(默认情况),那么可以在Activity ...

  4. android 虚拟按键挡住布局,Android 关于导航栏(虚拟按键)遮挡PopupWindow底部布局的问题...

    我们自定义popupWindow的时候,一般会设置这些参数 setContentView(contentView); //设置高度为屏幕高度 setWidth(UIUtils.getScreenHei ...

  5. android设置控件的坐标,Android中使PopupWindow显示在指定控件的上下左右!

    **1.View中的方法getLocationOnScreen(int[] location):获取该控件在屏幕中的绝对坐标并将坐标保存在数组中:如下图所示,A为屏幕的原点,R,C点即为view的绝对 ...

  6. android 中的PopupWindow

    android UI进阶之弹窗的使用 android 中的PopupWindow 弹出菜单 PopupWindow 转载于:https://www.cnblogs.com/Rocky_/archive ...

  7. Android中的PopupWindow详解

     Android的对话框有两种:PopupWindow和AlertDialog.它们的不同点在于: AlertDialog的位置固定,而PopupWindow的位置可以随意 AlertDialog ...

  8. 【Android UI设计与开发】第09期:底部菜单栏(四)Fragment+PopupWindow仿QQ空间最新版底部菜单栏

    转载请注明出处:http://blog.csdn.net/yangyu20121224/article/details/9023451          在今天的这篇文章当中,我依然会以实战加理论结合 ...

  9. 如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题

    如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题 参考文章: (1)如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题 (2)https://ww ...

  10. Android下PopupWindow隐藏及显示(showAtLocation/showAsDropDown)

    转载:http://orgcent.com/android-popupwindow-showasdropdown-showatlocation/ 上一篇对PopupWindow的用法(位置.动画.焦点 ...

最新文章

  1. android ui自动化测试工具,介绍Robotium+Orange实现androidUI自动化测试
  2. Android之属性动画初步
  3. 程序员加班很严重吗?看看国外程序员怎么怼老板!
  4. 超好看的引导购买页源码
  5. mysql架构 三级主从同步_MySQL 主从同步架构中你不知道的“坑”
  6. Hive查看执行计划
  7. kepware odata 接口访问地址
  8. 青花瓷 下载App Store上历史版本的App的ipa的包
  9. 荣耀V8鸿蒙系统刷机包,华为荣耀V8原版rom系统刷机包_荣耀V8最新版升级包更新下载...
  10. PCB表面贴片元件的手工焊接技巧
  11. Matlab 绘制 BP 神经网络图
  12. 王者战力查询教程,每天可查,数据准确~
  13. 6-1 单链表逆转 (20 分)
  14. 将Spring Boot应用程序迁移到Java 9-模块
  15. 古画会唱歌/图片说话对口型视频教程+工具素材
  16. 【区块链108将】流量之王的48小时生死转折
  17. android+手机运行卡,手机运行卡顿,运行内存太小,在购买的时候就需要注意运行速度...
  18. QT tableview内置控件
  19. php实现文件遍历,php ---- 文件遍历
  20. 心跳服务1.0(Heart Rate Service 1.0)

热门文章

  1. Android清单文件详解(三)----应用程序的根节点application
  2. C# 获取当前月第一天和最后一天 计算两个日期差多少天
  3. iOS网络编程-配置iCloud-图文解说
  4. [备忘]使用wcf联合服务
  5. ATC打ABC142有感
  6. 简(kun)单(nan)到让我开(jue)心(wang)的后缀自动机全家桶(普通后缀、广义后缀、子序列)...
  7. 重载函数与函数模板(转)
  8. 使用freemarker生成java文件(其他文件也可以)
  9. 以Attribute加上Header验证
  10. 19-spring学习-springMVC环境配置