[英]Android ListView Row Text Change Dynamically
I have a ListView with BaseAdapter and I create this adapter in my main Activity. 我有一个带有BaseAdapter的ListView,并且在主Activity中创建了此适配器。 In my adapter constructor, I also have an String list that fills the TextViews in ListView rows in "getView" method.
在我的适配器构造函数中,我还有一个字符串列表,该列表填充了“ getView”方法中ListView行中的TextViews。 After that, according to user interaction, I want to change text of TextViews in ListView rows, but how could I manage?
之后,根据用户交互,我想在ListView行中更改TextViews的文本,但是如何管理?
Update string or stirngs in your Adapter's "String list" and than call BaseAdapter's notifyDataSetChanged()
method. 更新适配器的“字符串列表”中的字符串或搅动,然后调用BaseAdapter的
notifyDataSetChanged()
方法。
This will notify all listeners that data is changed and in your particular case will result in ListView
re-fetching visible views from your Adapter. 这将通知所有侦听器数据已更改,并且在您的特定情况下,将导致
ListView
从适配器重新获取可见视图。 And your Adapter will return views with new updated strings. 并且您的适配器将返回带有新的更新字符串的视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.