- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我将 ListView 膨胀为 PopupWindow 中的 contentView。如果我不设置宽度和高度,我就看不到 PopupWindow。如果我这样设置它们:
setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
布局设置为“fill_parent”。为什么?
ListView和ListView item的布局属性都设置为“wrap_content”。有什么建议吗?谢谢。
最佳答案
这是怎么做的:
// Don't use this. It causes ListView's to have strange widths, similar to "fill_parent"
//popupWindow.setWindowLayoutMode(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
// Instead, use this:
final int NUM_OF_VISIBLE_LIST_ROWS = 4;
listView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
popupWindow.setWidth(listView.getMeasuredWidth());
popupWindow.setHeight((listView.getMeasuredHeight() + 10) * NUM_OF_VISIBLE_LIST_ROWS);
请注意,setWidth()
和 setHeight()
使用原始像素值,因此您需要针对不同的屏幕尺寸和不同的密度进行调整。
关于android - 如何在 Android 的 PopupWindow 中设置 ListView 的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4085093/
我想在另一个 PopUpWindow 中打开一个 PopUpWindow。我的 MainActivity 中有一个 ImageButtons。当我单击它时,会出现一个 PopUpWindow。我在我的
在 Honeycomb 应用程序中,我在多个地方使用 PopupWindow 的自定义子类来显示各种 View 。这一切都很好,直到其中一个 View 碰巧尝试显示另一个 PopupWindow。 例
android PopupWindow 可以显示另一个 PopupWindow 吗?可以同时打开多少个 PopupWindow?只有一个? 第一个PopupWindow正常显示。但是在单击按钮时(在第
在我的应用程序中,我试图将包含 popupwindow 的 View 设置为不可见,并在一段时间后设置为可见。我的弹出窗口包含图像和文本,我希望弹出窗口的整个 View 及其内容根据某种逻辑显示和不显
当从单独的类调用 PopupWindow 方法时,我希望能够从 xml 文件定义 PopupWindow 中的布局。下面的代码根据需要工作,除了布局是从 java 文件而不是 xml 文件中提取的。在
谷歌开发团队的人能解释一下如何避免在 pre-ics 设备上发生这种崩溃吗?在我的例子中,ListView 项目上的 ImageButton 是 PopupWindow 的 anchor ,用于创建下
PopupWindow 膨胀得很好,直到它接近屏幕底部,它被切断了。有谁知道当它接近屏幕底部时如何让它向上膨胀? public SelectBucketMenu(Context context) {
这个问题已经有答案了: Android popup window dismissal (11 个回答) 已关闭 9 年前。 我创建了弹出窗口 public void myPopUp() {
要创建一个简单的工作 PopupWindow,我们需要执行以下操作: popup_example.xml: Java代码 LayoutInflater infl
有 PopupWindow 的 xml 文件: 如何以编程方式替换此 xml 中的图标和背景? 最佳答案 LinearLayout menuLayout= (LinearLayout) activit
要创建一个简单的工作 PopupWindow,我们需要执行以下操作: popup_example.xml: Java代码 LayoutInflater infl
我想在向其添加布局之前让 PopupWindow 至少显示一个空矩形。 这不起作用: public void configure() { LinearLayout linearLayout =
我在使用 PopupWindow android 默认小部件时遇到了问题。当我触摸按钮显示弹出窗口而不是按手机上的后退按钮时,在显示弹出窗口之前,我有强制关闭消息,接下来是错误: 10-14
如何将键事件从可聚焦的 PopupWindow 分派(dispatch)到基础 Activity。如果我设置窗口可聚焦,它会消耗所有事件。我希望能够拦截一个 key ,并处理事件。 这是我的困境:我的
我想通过点击窗口外部或按下后退按钮来关闭 PopupWindow。现在你可以点击屏幕上的任何地方,窗口会关闭,我不明白为什么。我还想给 PopupWindow 添加一个阴影。谢谢! 主要 Activi
在我的一个 Activity 中,有一个按钮,单击它会打开一个PopupWindow。我的 Intent 是,当 PopupWindow 打开并且用户单击屏幕上弹出区域以外的任何地方时,应该关闭 Po
目前,我在线性布局中有一个按钮,如下所示: 我还有一个 createPopup 扩展(它确实在单击按钮时执行)。 public void createPopup(View view) {
我有一个用于显示谷歌地图的弹出窗口,但一旦它打开我似乎无法关闭它,我试图设置后退按钮以关闭它但无法调用 onBackButtonClick当我在 fragment 中时覆盖。虽然似乎没有做任何事情
我想像 Google Keep 在创建提醒时那样在虚拟键盘上方显示一个 PopupWindow: 最佳答案 我相信,您正在寻找的是以下组合: popupWindow.setSoftInputMode(
我如何显示和隐藏同一个弹出窗口,而不是每次都创建一个对象。这就是我创建窗口的方式。我不想解雇();并出于性能原因每次重新创建窗口。 popupWindow = new PopupWindow(
我是一名优秀的程序员,十分优秀!