0

I have 3 tabs with List Fragments('A','B' and 'C') and also have Navigation Drawer list that contains a list of data for filtering the content of the lists in the 3 tabs. What i want is that when i click on any item in Navigation Drawer list, the current tab content should refresh and should show new data in the list. If lets say we are in Tab A and select any item from Navigation Drawer, how do we send a string to Tab A, so that Tab A list content is refreshed?

Fragment Activity

    getActionBar().setDisplayShowTitleEnabled(false);
    getActionBar().setHomeButtonEnabled(false);
    getActionBar().setIcon(R.drawable.clip1);

    actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); 
    setTitle("Records");

    ActionBar.TabListener tabListener = new ActionBar.TabListener(){



        @Override
        public void onTabSelected(android.app.ActionBar.Tab tab,
                android.app.FragmentTransaction ft) {
            // TODO Auto-generated method stub
            Tab.setCurrentItem(tab.getPosition());

        }

        @Override
        public void onTabUnselected(android.app.ActionBar.Tab tab,
                android.app.FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTabReselected(android.app.ActionBar.Tab tab,
                android.app.FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }};
        //Add New Tab

        actionBar.addTab(actionBar.newTab().setText("A").setTabListener(tabListener));
        actionBar.addTab(actionBar.newTab().setText("B").setTabListener(tabListener));
        actionBar.addTab(actionBar.newTab().setText("C").setTabListener(tabListener));

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    CategoryDatabaseHandler dbcategory = new CategoryDatabaseHandler(this);
    categoryList=dbcategory.getCategoryList();
    DrawerItemCustomAdapter drawerAdapter = new DrawerItemCustomAdapter(this, categoryList);
    mDrawerList.setAdapter(drawerAdapter);

    mDrawerList.setOnItemClickListener(new OnItemClickListener(){

            @Override
              public void onItemClick(AdapterView<?> adapter, View v, int position,
                    long arg3) 
              {
                //actionBar.selectTab(actionBar.getSelectedTab());
              }
        });

Listfragment

MySimpleArrayAdapter myadapter = new MySimpleArrayAdapter(this.getActivity(),AList);

       setListAdapter(myadapter);

       ListView listView = getListView();


       listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
Abhi1988
  • 159
  • 2
  • 3
  • 14

1 Answers1

0

Check this out. You can register the LocalBroadcastManager listener to the fragment that you want and then from your MainActivity when an item is selected from the navigation drawer you will send a message to your fragment so it can refresh it's contend

Community
  • 1
  • 1
Panayiotis Irakleous
  • 2,696
  • 1
  • 23
  • 36