PopupView没有显示出来? [英] PopupView not showing up?

查看:467
本文介绍了PopupView没有显示出来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是XML(只是一个web视图):

 < XML版本=1.0编码=UTF-8&GT?;
<的WebView的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android机器人:ID =@ + ID / couponView机器人:layout_height =100dp机器人:layout_width =100dp/ >
 

和code:

 最后查看CVIEW = getLayoutInflater()膨胀(R.layout.couponlayout,空)。
PopupWindow PW =新PopupWindow(CVIEW);
pw.showAtLocation(findViewById(R.id.mainLayout),Gravity.CENTER,100,100);
pw.update();
 

这是一个button.onClick()方法。当我按一下按钮,那应该发生(按钮改变颜色,文字等),剩下的事,但PopupWindow显示不出来。我一直在梳理网络,但无法找到任何修复。我究竟做错了什么?

编辑:没有人知道怎么回事?我觉得这是一个常见的​​问题。

解决方案

  PopupWindow.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
 

Here's the XML (just a webview):

<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/couponView" android:layout_height="100dp" android:layout_width="100dp" />

and the code:

final View cView = getLayoutInflater().inflate(R.layout.couponlayout, null);
PopupWindow pw = new PopupWindow(cView);
pw.showAtLocation(findViewById(R.id.mainLayout), Gravity.CENTER, 100, 100);
pw.update();

This is in a button.onClick() method. When I click the button, the rest of the things that should happen (button changes color, text, etc.), but the PopupWindow doesn't show up. I've been combing the web but can't find any fixes. What am I doing wrong?

edit: no one knows whats going on? I feel like this is a common problem.

解决方案

PopupWindow.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

这篇关于PopupView没有显示出来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆