在运行时改变的ListView项目 [英] Altering ListView items at runtime

查看:112
本文介绍了在运行时改变的ListView项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这是在布局XML定义一个ListView。我还有一个XML whcih定义了每个在ListView和code使用充气机制的项目元素TextViews。有3 TextViews命名顶部,中部和底部。在ListView控件的运行时我的生活改变的一个ListView的项目在最后一行文本并导致两行文本的地方之一,它是。在TextViews XML的最下面一行有单行定义为假。

I have a ListView which is defined in a layout XML. I have another XML whcih defines TextViews that are elements in each of the items in the ListView and in code use the 'inflator' mechanism . There are 3 TextViews named top, middle and bottom. During the runtime life of the ListView I change some text in the bottom row of one the ListView items and it results in two lines of text in place of the one which it was. The bottom row in the TextViews XML has 'single line' defined as "false".

当应用程序正在运行,code修订底排在ListView项目出现两行文字之一,但由于ListView项的深度并没有改变文本半隐半现的第二行。

When the app is running and code amends the bottom row in one of the ListView items two lines of text appears but because the depth of the ListView item doesnt change the second line of text is half hidden.

我看了又看的XML和code,试图砌出如何修改ListView的项目,但没有成功的深度。能不能做到任何帮助,如何?
谢谢

I've pored over the XML and code to try to puzzle out how to amend the depth of the ListView item but without success. Can it be done and any help as to how? Thanks

推荐答案

ListView的绝对支持此方案。确保你的TextView的高度设置为wrap_content,也有一个最小高度上(因此,当有只有一行文字它们不会出现微小的。)当您更改行的内容,请确保调用notifyDatasetChanged() ListView的告诉它正确重新布局。

ListView definitely supports this scenario. Make sure your TextView have a height set to wrap_content and also have a minimum height (so they don't appear tiny when there's only one line of text.) When you change the content of a row, make sure to call notifyDatasetChanged() on ListView to tell it to relayout properly.

这篇关于在运行时改变的ListView项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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