Reputation: 142
I have a recycler view that fills with data at the application's start. It fills well everytime, but the recycler view doesn't update everytime. Clicking the action bar to open the keyboard refreshes it.
I also notify the recycler view for update after all of the data has finished loading.
I'm gonna add code and XML layouts if needed.
refresh/notify code:
// Inflate
new java.util.timer().schedule(
() -> {
runOnUiThread(()->{
adapter.notifyDataSetChanged();
});
}, 1000
);
Upvotes: 1
Views: 452
Reputation: 16813
Check following example to refresh recyclerview
in every 1 second.
Handler timerHandler;
timerHandler = new Handler();
Runnable timerRunnable = new Runnable() {
@Override
public void run() {
adapter.notifyDataSetChanged();
timerHandler.postDelayed(this, 1000);
}
};
timerHandler.postDelayed(timerRunnable, 1000);
Upvotes: 2