Reputation: 5234
I have 2 activity, one is ListFragmentActivity
and other is FragmentActivity
. In ListFragmentActivity i have list-view which i want to update run-time. and FragmentActivity contains different - different view's.
I have set of data on server and through PHP web service i am trying to load all data in ListFgagmentActivity's Listview but somehow i am not able to load all data. So what i need to do is just want to update ListFragment class Listview from FragmentActivity.
I have refereed below link but the solution is not working in my case.
How update ListView in ListFragment from FragmentActivity?
I am trying to do like this:
http://android-er.blogspot.sg/2012/06/communication-between-fragments-in.html.
But insted of text-view or edit-text i want to use list-view.
Thanks in advance. Any help would be appreciated..
Upvotes: 0
Views: 2199
Reputation: 368
you can create a method to update ListView in Fragment
public void updateList(ArrayAdapter adapter){
ListView listView = (ListView) rootView.findViewById(R.id.listView);
list.setAdapter(arrayAdapter);
}
and call it from your Activity:
Fragment fragment = new Fragment();
fragment.updateList(someAdapter);
just don't call it in OnCreate method, because then fragment is not yet inflated.
Upvotes: 1