【问题标题】:Listview inside popup window height is not changing弹出窗口高度内的Listview没有改变
【发布时间】:2014-06-09 09:50:47
【问题描述】:

我在弹出窗口中使用列表视图,列表视图显示一些动态内容。我想根据内容设置列表视图的高度,但它不应超过特定高度。由于我无法为该列表视图设置最大高度,因此我从它的适配器 getview 更改了列表视图的高度并在布局中使用了 wrapcontent .当内容大小增加时,Listview 的高度会发生变化。但是当内容大小减小时,大小并没有改变。

    if(co_get>11)
{               
    LayoutParams params =  new LayoutParams(LayoutParams.MATCH_PARENT, 600); 
    params.setMargins(10, 10, 10, 10);     
    parent.setLayoutParams(params);

}
else
{           
        LayoutParams params =  new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
        params.setMargins(10, 10, 10, 10);          
        parent.setLayoutParams(params);

}

这是我在 getview 中使用的代码。

【问题讨论】:

    标签: android android-listview height android-popupwindow


    【解决方案1】:

    在每次显示对话框之前调用 onPrepareDialog() 方法,以便您适当地更新它。

    @Override
    protected void onPrepareDialog(int id, Dialog dialog) {
        //Always call through to super implementation
        // your changings
    }
    

    【讨论】:

    • 我使用的是 PopupWindow 而不是对话框。
    【解决方案2】:

    我在收到通知时将 Layoutparams 设置为 listview。这样就解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      • 1970-01-01
      • 1970-01-01
      • 2011-10-31
      相关资源
      最近更新 更多