Reputation: 51
Im having a problem during an action in my activity. I have created a runnable, that runs on a thread. The thread checks if a textview has been swiped and moves the textview off screen. Once that textview is offscreen it removes it from the linearlayout. The layout does not update the textviews in it and leaves the space that the previous textview was at.
How it is now:
__________ __________ __________
|[item 1]| -----> |[item 1]| -----> |[item 1]|
|[item 2]| User |[swiped]| item 2 | |
|[item 3]| swipes |[item 3]| space |[item 3]|
|[item 4]| item 2 |[item 4]| remains |[item 4]|
|[item 5]| |[item 5]| |[item 5]|
---------- ---------- ----------
How I want it to run:
__________ __________ __________
|[item 1]| -----> |[item 1]| -----> |[item 1]|
|[item 2]| user |[swiped]| removed |[item 3]|
|[item 3]| swiped |[item 3]| view & |[item 4]|
|[item 4]| |[item 4]| update |[item 5]|
|[item 5]| |[item 5]| space | |
---------- ---------- ----------
I hope this explains what is going on and what I have. If not ill add more.
EDIT: If i lock and unlock my screen, it updates the UI, and the views are fixed. It seems I am looking for a refresh or maybe invalidate()?
Upvotes: 0
Views: 1199
Reputation: 8685
You probably want:
public void requestLayout()
Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (isInLayout(). If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.
Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.
Upvotes: 2