There is the following code from custom AsyncTask:
@Override
public void onPreExecute() {
setTitle();
dialog.show();
}
private void setTitle() {
Activity activity=(Activity)context;
TextView title=(TextView)activity.findViewById(R.id.textViewToDoListTitle);
Log.e("title", title.getText().toString());
title.setText("123");
Log.e("title", title.getText().toString());
}
This code works without exceptions, but setTitle() function doesn’t update text in TextView title! In log I can see that title stores “123” after executing the last row in setTitle(). But the value doesn’t update on the screen! How can I fix it?
Pass the original reference to the TextView instead of the context to the Activity and then calling setText on the TextView, should work 😉