添加动态线性布局,列表视图

编程入门 行业动态 更新时间:2024-10-21 23:24:20
本文介绍了添加动态线性布局,列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的是列表视图,以显示它的一些数据,并使用它与自定义适配器,现在的时间实例,我想显示的图像视图中有一个列表项。对于这种情况下,我做了动态线性布局,并添加其中的图像显示。现在我想,在某些条件下这个图像视图布局应作为列表项的出现在最后的列表视图作为一个新项目添加到列表中。

I am using a list view to show some data on it and using it with a custom adapter, now at an instance of time, I want to show an image view as a list item in it. For that case I have made dynamic linear layout and added the image view in it. Now I want that on some condition this image view layout should appear as the list item in the last of the list view as a new item added to the list.

Genarating布局动态

Genarating layout dynamically

LinearLayout linearLayout = new LinearLayout(UserChatActivity.this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); ImageView img = new ImageView(UserChatActivity.this); img.setImageBitmap(BitmapFactory.decodeFile(picturePath)); linearLayout.addView(img, layoutParams); mList.addView(linearLayout);

但它给命名的错误: - 视图不能在adapterViews直接添加。我知道,我们有夸大的观点适配器,但如何添加在列表中的previous数据来的新观点。???

But it is giving an error named : - Views can't be added directly in the adapterViews. I know that we have to inflate views for the adapter but how to add the new view with the previous data coming in the list.???

感谢

推荐答案

我觉得 MergeAdapter 完美解决您的问题。

I think MergeAdapter perfectly solves your problem.

更多推荐

添加动态线性布局,列表视图

本文发布于:2023-11-11 18:12:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579198.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   线性   布局   动态   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!