添加动态线性布局,列表视图 [英] Adding dynamic linear layouts to a list view

查看:114
本文介绍了添加动态线性布局,列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于添加动态线性布局,列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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