I have a Custom ListView in my application, containing an ImageView and 3-5 TextViews.
1 of the TextViews shows the time gap between the current time
Use a Handler
and its postDelayed
method to invalidate the list's adapter as follows:
final Handler handler = new Handler()
handler.postDelayed( new Runnable() {
@Override
public void run() {
adapter.notifyDataSetChanged();
handler.postDelayed( this, 60 * 1000 );
}
}, 60 * 1000 );
You must only update UI in the main (UI) thread.
By creating the handler in the main thread, you ensure that everything you post to the handler is run in the main thread also.