0

I have a AsyncTask and after it finishes execution I want to modify the NavigationDrawer's ListView, but I do not know how to do this.

This is my onCreateView() in NavigationDrawer Activity.

public View onCreateView(LayoutInflater inflater, ViewGroup container,
     Bundle savedInstanceState) {
  mDrawerListView = (ListView) inflater.inflate(
        R.layout.fragment_navigation_drawer, container, false);


  mDrawerListView
  .setOnItemClickListener(new AdapterView.OnItemClickListener() {
     @Override
     public void onItemClick(AdapterView<?> parent, View view,
           int position, long id) {

        selectItem(position);
     }
  });

  rowItems = new ArrayList<ListItem>();
  // Popolo.
  for (int i = 0; i < text.length; i++) {
     ListItem item = new ListItem(images[i], text[i]);
     rowItems.add(item);
  }

  CustomListViewAdapter adapter = new CustomListViewAdapter(getActionBar()
        .getThemedContext(), R.layout.list_item, rowItems);
  mDrawerListView.setAdapter(adapter);
  mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
  return mDrawerListView;
}

I want to modify a item in list from example by a AsyncTask.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
  • Can you be a bit more specific? Does the AsyncTask generate a single item, or all the items? What exactly is is changing or being modified in the AsyncTask? – RoraΖ Jul 22 '14 at 14:06
  • Hi, thank you for answer. My task must modify only 1 item. He must change the item's text and icon for example. I don't know how to modify the NavigationDrawer ListView. – user3732854 Jul 22 '14 at 14:20
  • can any one help me? :( – user3732854 Jul 22 '14 at 19:05
  • You have the rowItems ArrayList, you can modify the any of those items whenever you want to. If you've changed the data you can clear it and add them again, or call notifyDataSetChanged(). See this post: http://stackoverflow.com/a/21862750/1323014 As long as the AsyncTask has access to rowItems, or returns a new list for you to use that should solve your problem. – RoraΖ Jul 23 '14 at 01:31

0 Answers0