How to add elements to an Android ListView programmatically?
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.
精彩评论