开发者

How to add elements to an Android ListView programmatically?

开发者 https://www.devze.com 2022-12-11 06:56 出处:网络
I have a ListView with an adapter extending BaseAdapter. I create a view (from a LinearLayout and I put some items ont it depending on some parameters. I have a textview, with a drawable and sometime

I have a ListView with an adapter extending BaseAdapter. I create a view (from a LinearLayout and I put some items ont it depending on some parameters. I have a textview, with a drawable and sometime another textview next to the drawable in this horizontal linearlayout. For some reason, this command doesn't seems to work.

setLayoutParams(new
ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT,
          ListView.LayoutParams.WRAP_CONTENT));

So when my textview doesn't fill the full width of the list, I can only click on the part of the elements with the widget on it. I have try playing a lot with the layout and I can't get this to work. The parameters seems to be ignore all together. Only hack that would work I found was to set a big minimum width on my linearlayout but I don't think th开发者_运维问答at's the best solution.


Change everything ListView, LayoutContainer and TextView to FILL_PARENT, that should do the job.

0

精彩评论

暂无评论...
验证码 换一张
取 消