I am doing heavy network tasks - loading images (preview) - Since my main user interface was not blocked, he did it in AsyncTask, I want to put them in the GridView, but I installed the adapter before AsyncTask is complete. Some code will be more useful
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gridview); new LoadAllPictures().execute(); GridView g = (GridView) findViewById(R.id.gridview); g.setAdapter(new ImageAdapter(this)); }
So, at the end, Logcat shows that everything was loaded, but nothing on my screen. I tried to make the setAdapter part in my AsyncTask, but it tells me that: Only the original thread that created a view hierarchy can touch its views.
What should I do?
source share