Reputation: 6116
I have a menu ListView that has a dynamic SignOut row that should only show when the user is logged in. The ListView has a drop shadow after it (not set as a Footer, but rather as a View following the ListView). When I remove the SignOut row it disappears, but the size of the ListView does not change, so there is a transparent gap and then the dropshadow. I am hiding the SignOut row using signOutBtn.setVisibility(View.GONE);
(I have a reference to the signOutBtn View, which is a RelativeLayout). Also, I have verified I am not using View.INVISIBLE anywhere since I would expect this behavior using that.
The ListView is using wrap_content
for the height, and I believe this is where the problem lies - the height is being calculated including the SignOut button.
So, the question is, how can I make the ListView dynamically resize when a row is shown or hidden? I would prefer not to destroy and recreate the View, although that is what I will probably try next, since it is a relatively simple view.
PS. I can add code samples if needed.
Upvotes: 0
Views: 648
Reputation: 6116
In the end, I decided to just update the adapter data and remove or add the signOut row based on the user's login state. It was pretty simple, and I was able to remove quite a few conditionals based around showing / hiding the button, plus code that was there to assign a unique id to the signOut button in the ListView adapter so I could look it up to hide it.
Upvotes: 1