Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8621635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:51:48+00:00 2026-06-12T06:51:48+00:00

i have a main class that hold a actionbarsherlock with tabs and viewpager here

  • 0

i have a main class that hold a actionbarsherlock with tabs and viewpager

here is it:

public class HSG_Handball extends SherlockFragmentActivity
{
    ViewPager mViewPager;
    TabsAdapter mTabsAdapter;
    TextView tabCenter;
    TextView tabText;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        mViewPager = new ViewPager(this);
        mViewPager.setId(R.id.pager);

        setContentView(mViewPager);
        ActionBar bar = getSupportActionBar();
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        mTabsAdapter = new TabsAdapter(this, mViewPager);

        mTabsAdapter.addTab(bar.newTab().setText("Alle Spiele"), Spiele.class, null);
        mTabsAdapter.addTab(bar.newTab().setText("Tabelle"), Tabelle.class, null);
    }

    public static class TabsAdapter extends FragmentPagerAdapter implements ActionBar.TabListener, ViewPager.OnPageChangeListener
    {
        private final Context mContext;
        private final ActionBar mActionBar;
        private final ViewPager mViewPager;
        private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();

        static final class TabInfo
        {
            private final Class<?> clss;
            private final Bundle args;

            TabInfo(Class<?> _class, Bundle _args)
            {
                clss = _class;
                args = _args;
            }
        }

        public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager)
        {
            super(activity.getSupportFragmentManager());
            mContext = activity;
            mActionBar = activity.getSupportActionBar();
            mViewPager = pager;
            mViewPager.setAdapter(this);
            mViewPager.setOnPageChangeListener(this);
        }

        public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args)
        {
            TabInfo info = new TabInfo(clss, args);
            tab.setTag(info);
            tab.setTabListener(this);
            mTabs.add(info);
            mActionBar.addTab(tab);
            notifyDataSetChanged();
        }

        @Override
        public int getCount()
        {
            return mTabs.size();
        }

        @Override
        public Fragment getItem(int position)
        {
            TabInfo info = mTabs.get(position);
            return Fragment.instantiate(mContext, info.clss.getName(), info.args);
        }

        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels)
        {
        }

        public void onPageSelected(int position)
        {
            mActionBar.setSelectedNavigationItem(position);
        }

        public void onPageScrollStateChanged(int state)
        {
        }

        public void onTabSelected(Tab tab, FragmentTransaction ft)
        {
            Object tag = tab.getTag();
            for (int i = 0; i < mTabs.size(); i++)
            {
                if (mTabs.get(i) == tag)
                {
                    mViewPager.setCurrentItem(i);
                }
            }
        }

        public void onTabUnselected(Tab tab, FragmentTransaction ft)
        {
        }

        public void onTabReselected(Tab tab, FragmentTransaction ft)
        {
        }
    }

    public boolean onCreateOptionsMenu(Menu menu) 
    {

        SubMenu subMenu1 = menu.addSubMenu("Aktive");
        subMenu1.add("Herren 1");
        subMenu1.add("Herren 2");
        subMenu1.add("Herren 3");
        subMenu1.add("Damen 1");
        subMenu1.add("Damen 2");

        MenuItem subMenu1Item = subMenu1.getItem();
        subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        SubMenu subMenu2 = menu.addSubMenu("Jugend");
        subMenu2.add("männl. A");
        subMenu2.add("weibl. A");
        subMenu2.add("männl. B1");
        subMenu2.add("männl. B2");
        subMenu2.add("männl. C");
        subMenu2.add("männl. D");
        subMenu2.add("E-Jugend");

        MenuItem subMenu2Item = subMenu2.getItem();
        subMenu2Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        if(!item.getTitle().toString().equals("Active") || !item.getTitle().toString().equals("Jugend"))
        {
            new Spiele().FormatiereSpieleSeite(item.getTitle().toString());
        }
        return super.onOptionsItemSelected(item);
    }
}

the second class (Spiele) is a listfragment with a custom base adapter.
The class looks so:

public class Spiele extends ListFragment
{

String ligaId = "0";
SpieleAdapterFuerCustomList adapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
        View view = inflater.inflate(R.layout.spiele, container, false);

        List<String> dateAndSchiri = new ArrayList<String>();
        dateAndSchiri.add("DATUM  ·  Schiri 1 : Schiri 2");
        dateAndSchiri.add("DATUM  ·  Schiri 1 : Schiri 2");
        dateAndSchiri.add("DATUM  ·  Schiri 1 : Schiri 2");

        List<String> heim = new ArrayList<String>();
        heim.add("HSG Nieder-Roden");
        heim.add("SG Bruchköbel");
        heim.add("LOL Idiotenklupp");

        List<String> gast = new ArrayList<String>();
        gast.add("KG Wallau");
        gast.add("DJ G4bby");
        gast.add("Hanzup Motherf*ckers");

        adapter = new SpieleAdapterFuerCustomList(getActivity(), dateAndSchiri, heim, gast);
        setListAdapter(adapter);

        return view;
}

public void FormatiereSpieleSeite(String mannschaft)
    {
// aktive
        if(mannschaft.equals("Herren 1"))
            ligaId = "X0";
        if(mannschaft.equals("Herren 2"))
            ligaId = "00151350asd0";
        if(mannschaft.equals("Herren 3"))
            ligaId = "00151asdad000000000000000001000";
        if(mannschaft.equals("Damen 1"))
            ligaId = "001513asdad0000000007000";
        if(mannschaft.equals("Damen 2"))
            ligaId = "0015135asd0000000000003000";

// jugend
        if(mannschaft.equals("männl. A"))
            ligaId = "0015135asdasd0000000000001000";
        if(mannschaft.equals("weibl. A"))
            ligaId = "";
        if(mannschaft.equals("männl. B1"))
            ligaId = "001513asdasd0000000000000002000";
        if(mannschaft.equals("männl. B2"))
            ligaId = "00151350asd05502000000000000001000";
        if(mannschaft.equals("männl. C"))
            ligaId = "0015asdasd503000000000000001000";
        if(mannschaft.equals("männl. D"))
            ligaId = "001513504501asdsad0000001000";
        if(mannschaft.equals("E-Jugend"))
            ligaId = "0015135asdasd000000000003000";



    System.out.println(ligaId + "Das ist liga");

    List<String> dateAndSchiri = new ArrayList<String>();
    dateAndSchiri.add("DATUM as Schiri 2");
    dateAndSchiri.add("DATUMasas Schisdfsdfri 2");
    dateAndSchiri.add("DATUMasas Schirsdfsfi 2");

    List<String> heim = new ArrayList<String>();
    heim.add("HSG Nieder-sdfRoden");
    heim.add("SG Brucsdfhköbel");
    heim.add("LOL Idiosdfsdftenklupp");

    List<String> gast = new ArrayList<String>();
    gast.add("KG Walsdfsflau");
    gast.add("DJ G4sdfsfbby");
    gast.add("Hanzusdfsfp Motherf*ckers");

    adapter = new SpieleAdapterFuerCustomList(getActivity(), dateAndSchiri, heim, gast);
    adapter.notifyDataSetChanged();
    setListAdapter(adapter);

}

}

All is ok and run fine.

On the “main”-class. The class that holds the viewpager and tabsactionbar have menus. If the user click on one of them it must load a new ListFragment. Or a new BaseAdapter(?).
I want that the ListFragment (class: Spiele) is updatet.
But how can i do that?
How update my ListFragment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:51:49+00:00Added an answer on June 12, 2026 at 6:51 am

    The solution is easyer than i think.

    These https://stackoverflow.com/a/7393477/1231245 have helped me to find the FragmentTag from the first Fragment in ViewPager.

    I can easilie create and set the adapter in the onOptionsItemSelected method.
    Here is it:

            List<String> dateAndSchiri = new ArrayList<String>();
            dateAndSchiri.add.....
    
            List<String> heim = new ArrayList<String>();
            heim.add.....
    
            List<String> gast = new ArrayList<String>();
            gast.add.....
    
            SpieleAdapterFuerCustomList adapter = new SpieleAdapterFuerCustomList(getBaseContext(), dateAndSchiri, heim, gast);
            Spiele articleFrag = (Spiele) getSupportFragmentManager().findFragmentByTag("android:switcher:"+R.id.pager+":0");
            articleFrag.setListAdapter(adapter);
    

    you can create a new adapter with different ArrayList’s with different click on menu…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class to hold data and a list of that class. Here
I have a main class in a program that launches another class that handles
So I have a main class and another class that has a variable I
I have a main class and two extended classes: class Main { public $foo;
I have a class that should hold a reference to some data, without owning
I have a specific class in my project that used for load and hold
I have four tabs that hold four listviews, I want to set a background
I have my main class PayUnit where I create my main object references, such
I have one main class with several inherited members who all overload the same
I have a main class(which is basically a netbeans form;drag and drop) from where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.