简体   繁体   English

单击按钮即可重新加载列表内容

[英]reload list contents on click of a button

i am trying to develop this app in android that has 3-4 buttons and a list being displayed below them. 我正在尝试在android中开发此应用,该应用具有3-4个按钮,并在其下方显示一个列表。 each button when clicked must reload the list with new contents based on which button was clicked. 每个按钮在单击时必须根据单击的按钮重新加载列表中的新内容。 each row in the list has a picture and two lines of text. 列表中的每一行都有一张图片和两行文本。 could some one please suggest me how do I perform the reloading part. 有人可以建议我如何执行重装部分。

将具有更新的元素的新适配器与listView附加在一起,它将像重新加载列表视图一样工作……

You could grab the list, in whatever layout it is in (ex LinearLayout) by doing a: 您可以执行以下操作以列表的形式(例如LinearLayout)获取列表:

LinearLayout ll = (LinearLayout)getViewById(R.id.thislayout)

Remove the elements from the list as you desire using: 使用以下方法从列表中删除元素:

ll.removeView(view);

edit the view object as you want (changing the source etc) then re-add it to the LinearLayout using: 根据需要编辑视图对象(更改源等),然后使用以下命令将其重新添加到LinearLayout中:

ll.addView(view);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM