Hello guys I'm trying to update the UI after a short delay and for this I'm using handler's postdelayed method. The following code initially sets my textview text to "Processing" and the code that's included in the the handler's runnable gets executed but doesn't update the UI? Please note that this is done in a Fragment
TextView progressText=(TextView)parent.findViewById(R.id.inProgressText);
progressText.setText("Processing");
getActivity().getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
TextView progressText=(TextView)parent.findViewById(R.id.inProgressText);
progressText.setText("Request completed");
}
}, 3000);
Thanks for your help
Change
getActivity().getMainLooper()).postDelayed(new Runnable()
to:
final Handler handler = new Handler();
Then
handler.postDelayed(new Runnable() {
@Override
public void run() {
final TextView progressText=(TextView)findViewById(R.id.inProgressText);
progressText.setText("Request completed");
}
}, 3000);
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