Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AgendaFragment agenda = new AgendaFragment();
- String label = getResources().getString(R.string.title_activity_list);
- FragmentTransaction ft = getFragmentManager().beginTransaction();
- Bundle bundle = new Bundle();
- bundle.putString("date", date);
- agenda.setArguments(bundle);
- ft.replace(R.id.pager, agenda, label);
- ft.commit();
- public class AgendaFragment extends Fragment {
- private Context mContext;
- ArrayList<String> mDate;
- Vector<List<String>> mMappedInfo;
- @Override
- public void onActivityCreated(Bundle savedInstanceState){
- super.onActivityCreated(savedInstanceState);
- mContext = (Context) getActivity();
- mDate = new ArrayList<String>();
- mMappedInfo = new Vector<List<String>>();
- //...
- //Get necessary information from server.
- serverCommunication();
- }
- private void serverCommunication() {
- new AsyncTask<Void, Void, Boolean>() {
- //get information
- @Override
- protected void onPostExecute(Boolean result) {
- super.onPostExecute(result);
- if (result) {
- //parse data
- apptXmlParsing(mCompleteXml);
- }
- }
- }.execute();
- }
- public void apptXmlParsing(final XmlDom completeXml) {
- //Parse received data
- populateListView();
- }
- private void populateListView(){
- final ExpandableListView eLV = (ExpandableListView) getActivity().findViewById(R.id.expListView);
- //process data into acceptable format
- ExpandableListAdapter listAdapter = new ExpandableListAdapter(mContext, mDate, mMappedInfo, mCurrDate);
- eLV.setAdapter(listAdapter);
- }
- }
- public ExpandableListAdapter(Context c, List<String> mDate, ArrayList<HashMap<String, String>> mMappedInfo, List<String> mCurrDate) {
- this.context = c;
- this.mDateVariable = mDate;
- this.mMappedInfoVariable = mMappedInfo;
- this.mCurrDateVariable = mCurrDate;
- }
- // use the Objects with the new datas as parameters
- public void loadNewData(List<String> NewmDate, ArrayList<HashMap<String, String>> NewmMappedInfo, List<String> NewmCurrDate) {
- // Then, repopulate your variables
- this.mDateVariable = NewmDate;
- this.mMappedInfoVariable = NewmMappedInfo;
- this.mCurrDateVariable = NewmCurrDate;
- // Call the method to redraw your list item
- notifyDataSetChanged();
- }
- listAdapter.loadNewData(mDate,mMappedInfo,mCurrDate);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement