PopupWindow的使用
来源:互联网 发布:淘宝申请介入问题描述 编辑:程序博客网 时间:2024/06/06 01:12
1. 布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@color/white"> <View android:layout_width="match_parent" android:layout_height="0.5dp" android:background="@color/divider_color" /> <ListView android:id="@+id/lv_popup_per_seek_result_location" android:layout_width="match_parent" android:layout_height="match_parent"/></LinearLayout>
2.初始化
oncreate中调用 initNearByPopupWindow();/** * 配置区域范围的PopupWindow */private void initNearByPopupWindow() { final View popupView = LayoutInflater.from(this).inflate(R.layout.popupwindow_per_seek_result_scope, null); nearByPopupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); //实例化一个ColorDrawable颜色为半透明 nearByPopupWindow.setBackgroundDrawable(new BitmapDrawable()); nearByPopupWindow.setFocusable(true); nearByPopupWindow.setOutsideTouchable(true); nearByPopupWindow.update(); lvNearBy = (ListView) popupView.findViewById(R.id.lv_popup_per_seek_result_location); adapterDistance=new PerSeekDistanceAdapter(PerSeekResultActivity.this); lvNearBy.setAdapter(adapterDistance); lvNearBy.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { do something } }); //监听PopupWindow 取消时,回调方法, 可以做一些操作 nearByPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener(){ @Override public void onDismiss() {do something} } );}3 展示
List<String> listDistances= Arrays.asList(distances); //数据源adapterDistance.clean();adapterDistance.addAll(listDistances);nearByPopupWindow.showAsDropDown(rlNearby,0,-5);//展示 及位置
阅读全文
0 0
- Android PopupWindow的使用
- Android PopupWindow的使用
- Android PopupWindow的使用!!!
- 关于popupWindow的使用
- PopupWindow的使用
- PopupWindow的使用例子
- PopupWindow的使用
- popupWindow的使用心得
- PopupWindow的使用
- PopupWindow的使用
- Android PopupWindow的使用!!!
- PopupWindow的使用
- PopupWindow的使用
- popupWindow的使用
- PopupWindow的使用
- PopupWindow的使用
- Popupwindow的使用
- PopupWindow的使用
- [转]https配合移动端开发
- Java线程面试题 Top 50
- CSS 加粗(css font-weight)
- 解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
- 关于回调函数的学习1
- PopupWindow的使用
- javascript黑科技之高效填充
- Qt鼠标拖动ScrollArea代替鼠标滚轮操作
- 关于模板匹配的基础知识
- 实现简单的一页展示多条数据左右翻页功能
- Shade in spring-boot-starter-parent is misconfigur
- 多进程小demo
- JAVA实现斐波那契数列
- 18秋招面经