Reputation: 6081
Introduction
Hi, what I basically want to do is to add a view at the bottom of my layout.
Detailed information
I have a scroll view with 5 results. Those 5 results are generated through a for-loop and displayed in an async task. The first time I run the app a progress bar (loading circle from now on) appears and signals the user that he has to wait. The progress bar is done via XML. The rest of the layout is done programmatically. When the user now scrolls to the end of the display another 5 results are loaded. What I want to now is to signal it to the user by displaying a loading circle again.
Previous I used linearlayout.removeView(progressBar)
to remove the progress bar but now I also want to add a loading circle when the rest of the results are being displayed.
Approach
What I tried to use was to not use linearlayout.removeView(progressBar)
but to use progressBar.setVisibility(View.GONE/View.VISIBLE)
instead depending on if I want to make it visible or not
Problem encountering
The problem I have now is, that the loading circle is always displayed at the top of the android app, but I want it to be shown at the bottom of my results so the user actually sees the progressBar.
What I want to achieve
Basically just that the progressBar is at the bottom of the screen and not at the top of it. How do I achieve this?
Upvotes: 0
Views: 1317
Reputation: 1967
what you can try out is linearlayout.removeView(progressBar)
when the results are done loading.. then when you scroll down.. you again add this progressBar
to the linearlayout
i.e., linearlayout.addView(progressBar);
.
That'll do it for you..
Edit:
Doing something like this would not throw any exception:
View v = linearlayout.getChildAt(linearlayout.getChildCount()-1);
if(v != progressBar)
linearlayout.addView(progressBar);
Upvotes: 1