Android PopupWindow与ListView配合使用

本文详细介绍了在Android中如何使用PopupWindow显示一个包含ListView的弹窗,并解决ListView无法点击、高度调整以及如何通过Back键取消PopupWindow的问题。通过实例代码展示了PopupWindow的初始化、ListView的设置以及监听事件的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前几天用到了PopupWindow,在PopupWindow上面放了个ListView,在使用过程中遇到了以下问题:

一、PopupWindow上面的ListView无法点击;

二、PopupWindow上面ListView的高度调整;

三、PopupWindow无法用Back键取消。

下面来具体介绍一下PopupWindow的使用:

首先布局PopupWindow:1个ListView

<?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="wrap_content"
    android:baselineAligned="false"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/popListLayout"
        android:layout_width="match_parent"
        android:layout_hei
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值