GridView is not updated (Android)

0

I am creating an app that when it launches it executes an asynchronous task that makes a query to an api, when picking up the result it inserts in the adapter. I have tried it in several ways, but only the images appear when I select it in the sort by menu and the task is executed again.

asked by anonymous 02.11.2016 / 20:42

1 answer

0

This is happening because you are modifying the adapter data, but you are not "alerting" to it. To do this, just call the m_MoviewAdapter.notifyDataSetChanged() method after adding or removing a movie

Modify the onPostExecute() method of your FetchMoviesTask to:

@Override
    protected void onPostExecute(List<Movie> result) {
        m_MovieAdapter.clear();
        if(result != null) {
            for (Movie movie : result) {
                m_MovieAdapter.add(movie);
            }

         m_MoviewAdapter.notifyDataSetChanged();
        }
        m_ProgressDialog.dismiss();
    }
    
04.11.2016 / 12:51