Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i extend the size of a listview dynamically in java code

I am using a listview in a layout with a size- not in full size of layout. Below the layout there are components like button. I need the layout to get extended when more number of listitems adds dynamically.

I have kept the listview and buttons in scrollview.

Is there any attribute or option to make listview of variable length

like image 691
arnp Avatar asked Feb 20 '26 08:02

arnp


1 Answers

You should not have a listview inside a scrollview. Instead of having a listview you should add your items to a linearlayout, which will grow to accomodate the items and not enable the scrollbar within itself. This will solve your UI issue. You can set the onclickListeners in a for looop.

Update

<ScrollView.....>
    <LinearLayout .....>
       <LinearLayout ..../> // this has your list items
       <Button .... /> // you can have a layout here if you have multiple buttons.
    </LinearLayout>
</ScrollView>
like image 164
Ronnie Avatar answered Feb 22 '26 22:02

Ronnie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!