I m coding some ui screens on android. sometime I need to see ui changes immediately, but that changes can be seen on next ui thread request. so, for example if I remove a view on screen and add another view programmatically, then change whole view (with viewAnimator), removing view can be observed, but new view can not be observed. I m sure new view is added, because when I go back to first page, new view is on screen.
which function should I call add or remove some view on screen to see its effect immediatlety ?
I tried invalidate(), but it doesnt work for my case
The only way to run it again is to delete the content of one of the fields, then click outside the box (I assume this sets the condition to false) then I can add new text to the field and the UI Policy finally runs again.
Using a worker thread is probably the best way, but if you want another option you can take a look here - seems that you can update the UI using the Dispatcher .PushFrame () API. Unfortunetly nobody seems to know how safe is this method. Another idea is to use the OnIdle () function and do one iteration per call.
If you choose to apply the change immediately, it occurs immediately. If you don't choose to apply the change immediately, and you change the setting from a nonzero value to another nonzero value, the change is applied asynchronously, as soon as possible. Otherwise, the change occurs during the next maintenance window.
When you modify a DB instance, you can apply the changes immediately. To apply changes immediately, you choose the Apply Immediately option in the AWS Management Console. Or you use the --apply-immediately parameter when calling the AWS CLI or set the ApplyImmediately parameter to true when using the Amazon RDS API.
It sounds like, if you say the UI only updates on the next UI thread request, that you are modifying UI elements from another thread. Therefore, you must modify them in a Runnable using runOnUiThread. So, for example:
//example code
//where you are trying to modify UI components, do this instead
runOnUiThread(new Runnable(){
public void run(){
//update UI elements
}
});
The best way to ensure that a change will be made to a view as soon as the view is ready is to add a Runnable
to the view's message queue:
view.post(new Runnable(){
@Override
public void run() {
//TODO your code
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With