Example usage for android.app ActionBar addTab

List of usage examples for android.app ActionBar addTab

Introduction

In this page you can find the example usage for android.app ActionBar addTab.

Prototype

@Deprecated
public abstract void addTab(Tab tab);

Source Link

Document

Add a tab for use in tabbed navigation mode.

Usage

From source file:com.yuya.routerecorder.FragmentTabs.java

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

    instance = this;

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    //bar.setDisplayShowCustomEnabled(true);

    //bar.setDisplayShowTitleEnabled(false);
    //bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowCustomEnabled(false);

    bar.addTab(bar.newTab().setIcon(R.drawable.world_white)
            .setTabListener(new TabListener<RouteMapFragment>(this, "Show Map", RouteMapFragment.class)));

    bar.addTab(bar.newTab().setIcon(R.drawable.pen_white_frame)
            .setTabListener(new TabListener<AddRouteFragment>(this, "Add Trip", AddRouteFragment.class)));

    bar.addTab(bar.newTab().setIcon(R.drawable.list_new)
            .setTabListener(new TabListener<MyListFragment>(this, "Show List", MyListFragment.class)));

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }// www . j a v  a 2  s  .  c o  m

    //FragmentManager manager = getSupportFragmentManager();
    //fragmentA = (RouteMapFragment) manager.findFragmentById(R.id.map);
    //fragmentB = (AddRouteFragment) manager.findFragmentById(R.id.fragment_container);

}

From source file:scmu.nutweet.bluetooth.BluetoothChat.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)/*from  w  ww .j a  v  a2s .c  om*/
        Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    setContentView(R.layout.activity_chat);

    // Set up the action bar to show tabs.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // For each of the sections in the app, add a tab to the action bar.
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.friends_black).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.chatmsg_black).setTabListener(this));

    //stateChange(Const.mService.getState());
}

From source file:com.kosbrother.houseprice.ActionBarTabs.java

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

    setContentView(R.layout.action_bar_tabs);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // actionBar.setDisplayShowTitleEnabled(false);
    if (Build.VERSION.SDK_INT >= 14) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }/*from   w w  w  . j  a v a2  s .c o m*/
    actionBar.addTab(actionBar.newTab().setText("")
            .setTabListener(new TabListener("http://m.yungching.com.tw/", "YungChing")));
    actionBar.addTab(actionBar.newTab().setText("")
            .setTabListener(new TabListener("http://m.sinyi.com.tw/", "SinYi")));
    actionBar.addTab(actionBar.newTab().setText("591")
            .setTabListener(new TabListener("http://m.591.com.tw/mobile-index.html?f=app", "591")));
    CallAds();

}

From source file:com.raypold.raypoldcounter.MainActivity.java

@Override
protected void onCreate(Bundle arg0) {

    super.onCreate(arg0);
    setContentView(R.layout.activity_main);

    context = getApplicationContext();//from  ww  w . jav a  2  s  . co  m
    setFragmentManager();
    detectFirstRun();

    /*
     * Open the sharedPreference files for the actionBar functions extended
     * in ActionBarHandler
     */
    preferences = getSharedPreferences("userPreferences", 0);
    savedCounters = getSharedPreferences("savedCounters", 0);

    /* Create the action bar */
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager()));

    setTabNames();

    /* Create the navigation tabs and add them to the action bar */
    for (String tabName : tabNames) {
        actionBar.addTab(actionBar.newTab().setText(tabName).setTabListener(this));
    }

    /* Synchronize the the swiping and the highlighted tab view */
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int arg0) {
            actionBar.setSelectedNavigationItem(arg0);
        }
    });
}

From source file:com.plnyyanks.frcnotebook.activities.ViewTeam.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceHandler.getTheme());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_team);

    activity = this;

    ActionBar bar = getActionBar();
    bar.setTitle(teamNumber != -1 ? "Team " + teamNumber : "All Data");

    //tab for team overview
    ActionBar.Tab teamOverviewTab = bar.newTab();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    teamOverviewTab.setText("All Notes");
    teamOverviewTab.setTag("all");
    teamOverviewTab.setTabListener(this);
    bar.addTab(teamOverviewTab);
    bar.setDisplayHomeAsUpEnabled(true);

    //add an actionbar tab for every event the team is competing at
    ArrayList<String> events;
    if (teamNumber == -1) {
        events = StartActivity.db.getAllEventKeys();
    } else {// ww  w.  java 2s .  c  o m
        Team team = StartActivity.db.getTeam(teamKey);
        events = team.getTeamEvents();
    }
    for (String eventKey : events) {
        Log.d(Constants.LOG_TAG, "Making AB Tab for " + eventKey);
        Event event = StartActivity.db.getEvent(eventKey);
        if (event == null)
            continue;
        ActionBar.Tab eventTab = bar.newTab();
        eventTab.setTag(event.getEventKey());
        eventTab.setText(event.getShortName());
        eventTab.setTabListener(this);
        bar.addTab(eventTab);
    }

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM, 0));
    } else {
        bar.setSelectedNavigationItem(0);
    }

}

From source file:com.actionbarsherlock.sample.styled.MainActivityICS.java

/** Called when the activity is first created. */
@Override/*from w ww  .  ja v  a2  s  . co  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_PROGRESS);

    setContentView(R.layout.main);
    final ActionBar ab = getActionBar();

    // set defaults for logo & home up
    ab.setDisplayHomeAsUpEnabled(showHomeUp);
    ab.setDisplayUseLogoEnabled(useLogo);

    // set up tabs nav
    for (int i = 1; i < 4; i++) {
        ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this));
    }

    // set up list nav
    ab.setListNavigationCallbacks(
            ArrayAdapter.createFromResource(ab.getThemedContext(), R.array.sections,
                    android.R.layout.simple_spinner_dropdown_item),
            //              .createFromResource(this, R.array.sections,
            //                      android.R.layout.simple_spinner_dropdown_item),
            new OnNavigationListener() {
                @Override
                public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                    // FIXME add proper implementation
                    //rotateLeftFrag();
                    return false;
                }
            });

    // default to tab navigation
    showTabsNav();

    // create a couple of simple fragments as placeholders
    //        final int MARGIN = 16;
    //        leftFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN);
    //        rightFrag = new RoundedColourFragment(getResources().getColor(
    //                R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN,
    //                MARGIN);
    //
    //        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    //        ft.add(R.id.root, leftFrag);
    //        ft.add(R.id.root, rightFrag);
    //        ft.commit();

    ((Button) findViewById(R.id.start)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMode = startActionMode(new AnActionModeOfEpicProportions());
        }
    });
    ((Button) findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMode != null) {
                mMode.finish();
            }
        }
    });

    ((Button) findViewById(R.id.progress)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mProgress == 100) {
                mProgress = 0;
                mProgressRunner.run();
            }
        }
    });

}

From source file:com.hybris.mobile.activity.LoginActivity.java

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

    setContentView(R.layout.activity_login);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    Fragment[] frags = { new LoginFragment(), new RegistrationFragment() };
    FragmentPagerAdapter adapter = new TabsAdapter(getFragmentManager(), frags);
    mViewPager.setAdapter(adapter);/*from   w w w . java2s  .c o  m*/
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getActionBar().setSelectedNavigationItem(position);
        }
    });

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    MyTabListener tabListener = new MyTabListener(mViewPager, actionBar);
    Tab tab = actionBar.newTab().setText(R.string.tab_login).setTabListener(tabListener);
    actionBar.addTab(tab);

    tab = actionBar.newTab().setText(R.string.tab_register).setTabListener(tabListener);
    actionBar.addTab(tab);
    actionBar.setSelectedNavigationItem(0);

    // Handler to handle different asynchronous cases:
    // - When the user arrives from the scanning activity and scan a barcode that needs the user to be logged in, 
    mHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            // Error retrieving the data of the scanned value, we finish the activity and display a error message
            case BarCodeScannerActivity.MSG_DATA_ERROR:
                showMessage((String) msg.obj);
                finish();
                break;

            // Data available, we can start the activity associated with the intent
            case BarCodeScannerActivity.MSG_DATA_AVAILABLE:
                if (mIntentBarcodeAfterLogin != null) {
                    mIntentBarcodeAfterLogin.startActivity();
                    finish();
                }
                break;

            }

        }

    };

}

From source file:com.eu.lad.JamCamViewer.JamCamViewerMainActivity.java

/**
 * Called when the activity is first created.
 *///from  w w w.  jav  a  2s.  c  o m
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Check that the activity is using the layout version with
    // the main_fragment_container FrameLayout
    if (findViewById(R.id.route_pager) != null) {

        // However, if we're being restored from a previous state,
        // then remove any saved support fragments to avoid overlapping
        // the Action bar.
        if (savedInstanceState != null) {
            return;
        }

        // Initialise the route inventory
        routeInventory = new LinkedList<Route>();
        seedBaseData();

        // Set-up the tabs in the Action Bar
        final ActionBar actionBar = getActionBar();
        // Specify that tabs should be displayed in the action bar.
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        // Add a tab for each route in the routeInventory
        for (Route r : routeInventory) {
            ActionBar.Tab routeTab = actionBar.newTab();
            routeTab.setText(r.getRouteLabel());
            routeTab.setTabListener(this.getTabListener());
            actionBar.addTab(routeTab);
        }
    }

}

From source file:com.plnyyanks.frcnotebook.activities.ViewEvent.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceHandler.getTheme());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_event);

    activity = this;

    if (event == null) {
        Intent intent = new Intent(this, StartActivity.class);
        startActivity(intent);/*from   w ww  . j  av a  2  s .  com*/
        return;
    }

    ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setTitle(event.getEventName());
    bar.setSubtitle("#" + key);
    bar.setDisplayHomeAsUpEnabled(true);

    //tab for team list
    ActionBar.Tab teamListTab = bar.newTab();
    teamListTab.setText("Teams Attending");
    teamListTab.setTabListener(this);
    bar.addTab(teamListTab);

    //tab for match schedule
    ActionBar.Tab scheduleTab = bar.newTab();
    scheduleTab.setText("Match Schedule");
    scheduleTab.setTabListener(this);
    bar.addTab(scheduleTab);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM, 0));
    } else {
        bar.setSelectedNavigationItem(0);
    }
}

From source file:fr.leicht.androideip.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mContext = this;
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // For each of the sections in the app, add a tab to the action bar.
    actionBar.addTab(actionBar.newTab().setText(R.string.title_section1).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_section2).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_section3).setTabListener(this));

    Thread threadInit = new Thread(new Runnable() {

        public void run() {
            Message msg = null;//from   ww  w  .j a  va 2s .  c o m
            try {
                comm = new SimpleLogixCommunicator("192.168.1.18", 0xAF12);
                //Declaration des Tag
                myTags.add(EJP = new Tag(comm, "EJP", 30000));
                myTags.add(Temp_Ext = new Tag(comm, "Temp_Ext", 60000));
                myTags.add(Temp_Confort_Quentin = new Tag(comm, "Temp_Confort_Quentin", 10000));
                myTags.add(Temp_Confort_Salle = new Tag(comm, "Temp_Confort_Salle", 10000));
                myTags.add(Temp_Confort_Tim = new Tag(comm, "Temp_Confort_Tim", 10000));
                myTags.add(Temp_Tim = new Tag(comm, "Temp_Tim", 60000));
                myTags.add(Temp_Salle = new Tag(comm, "Temp_Salle", 60000));
                myTags.add(Temp_Quentin = new Tag(comm, "Temp_Quentin", 60000));
                myTags.add(Autorisation_IHM_Plancher = new Tag(comm, "Autorisation_IHM_Plancher", 5000));
                myTags.add(BP_IHM_Chauffage_Quentin = new Tag(comm, "BP_IHM_Chauffage_Quentin", 5000));
                myTags.add(BP_IHM_Chauffage_Salle = new Tag(comm, "BP_IHM_Chauffage_Salle", 5000));
                myTags.add(BP_IHM_Chauffage_Tim = new Tag(comm, "BP_IHM_Chauffage_Tim_Enabled", 5000));
                myTags.add(intensite_A = new Tag(comm, "intensite_A", 1000));
                myTags.add(Temp_Veranda = new Tag(comm, "Temp_Veranda", 60000));
                myTags.add(BP_IHM_Light_SS_Milieu = new Tag(comm, "BP_IHM_Light_SS_Milieu", 60000));
                myTags.add(Light_SS_Milieu = new Tag(comm, "Light_SS_Milieu", 500));

                myTags.add(BP_IHM_Light_SS_Chenil = new Tag(comm, "BP_IHM_Light_SS_Chenil", 60000));
                myTags.add(Light_SS_Chenil = new Tag(comm, "Light_SS_Chenil", 500));

                myTags.add(BP_IHM_Light_SS_Garage = new Tag(comm, "BP_IHM_Light_SS_Garage", 60000));
                myTags.add(Light_SS_Garage = new Tag(comm, "Light_SS_Garage", 500));

                myTags.add(Time_Reste_Light_Devant = new Tag(comm, "Time_Reste_Light_Devant", 500));
                myTags.add(BP_IHM_Light_Devant = new Tag(comm, "BP_IHM_Light_Devant", 50000));
                myTags.add(BP_IHM_Off_Light_Devant = new Tag(comm, "BP_IHM_Off_Light_Devant", 50000));
                myTags.add(Light_Devant = new Tag(comm, "Light_Devant", 5000));

                Hora = new Tags(comm, "Hora", 7);

                enExecution = true;
                Integer i = 0;
                while (enExecution) {
                    try {
                        i++;
                        for (Tag tag : myTags) {
                            tag.updateTag();
                        }
                        /*Hora.updateTag();
                        for (int k=0;k<7;k++) {
                           Log.d("[EIP]","Hora :"+Hora.getStringValue(k)+"/"+k);
                        }*/
                        //Log.d("[AndroidEIP]Main","WRITE Cycle :"+i);
                        UpdateIHM("Cycle :" + i);

                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (PathSegmentException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (ItemNotFoundException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (ProcessingAttributesException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (InsufficientCommandException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (InsufficientNrOfAttributesException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (OtherWithExtendedCodeException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (ResponseBufferOverflowException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (InvalidTypeException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    } catch (EmbeddedServiceException e) {
                        Log.d("[AndroidEIP]Main", e.getMessage());
                    }
                }
            } catch (IOException e) {
                msg = mHandler.obtainMessage(MSG_ERR, (Object) e.getMessage());
                mHandler.sendMessage(msg);
                Log.d("[AndroidEIP]Main", e.getMessage());
            } catch (NotImplementedException e) {
                msg = mHandler.obtainMessage(MSG_ERR, (Object) e.getMessage());
                mHandler.sendMessage(msg);
                Log.d("[AndroidEIP]Main", e.getMessage());
            }
        }
    });

    threadInit.start();

}