Pages Navigation Menu

Coding is much easier than you think

Navigation Types in new Android SDK Tools

Navigation Types in new Android SDK Tools

Android SDK Tools Revision 20 also provides various Navigation Types for Blank activity. To use the template of Navigation Type, minimum SDK version of at least 14 is required. The various navigation templates available are as follows
** UPDATE: Android Complete tutorial now available here.


Mostly this type of navigation type is used for action bars.

When you want to provide navigation tabs in an activity, using the action bar’s tabs is a great option (instead of using TabWidget), because the system adapts the action bar tabs for different screen sizes—placing them in the main action bar when the screen is sufficiently wide, or in a separate bar (known as the “stacked action bar”) when the screen is too narrow


Tabs + Swipe

Mostly this type of navigation type is used for action bars.


Swipe Views + Title Strip

Mostly this type of navigation type is used for action bars.



Mostly this type of navigation type when action bars are provided with drop down options.

As another mode of navigation (or filtering) within your activity, the action bar offers a built in drop-down list. For example, the drop-down list can offer different modes by which content in the activity is sorted.


Let€™s see how a sample Swipe Views + Title strip looks like when you just create a project using this navigation type and run it as such without editing its activity or source file.

Src : Navigation.java

package com.simplecodestuffs.navigationtype;
import android.app.ActionBar;
import android.app.FragmentTransaction;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class MainActivity extends FragmentActivity {

     * The {@link android.support.v4.view.PagerAdapter} that will provide fragments for each of the
     * sections. We use a {@link android.support.v4.app.FragmentPagerAdapter} derivative, which will
     * keep every loaded fragment in memory. If this becomes too memory intensive, it may be best
     * to switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}.
    SectionsPagerAdapter mSectionsPagerAdapter;

     * The {@link ViewPager} that will host the section contents.
    ViewPager mViewPager;

    public void onCreate(Bundle savedInstanceState) {
        // Create the adapter that will return a fragment for each of the three primary sections
        // of the app.
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.pager);


    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;

     * A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the primary
     * sections of the app.
    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {

        public Fragment getItem(int i) {
            Fragment fragment = new DummySectionFragment();
            Bundle args = new Bundle();
            args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
            return fragment;

        public int getCount() {
            return 3;

        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0: return getString(R.string.title_section1).toUpperCase();
                case 1: return getString(R.string.title_section2).toUpperCase();
                case 2: return getString(R.string.title_section3).toUpperCase();
            return null;
     * A dummy fragment representing a section of the app, but that simply displays dummy text.
    public static class DummySectionFragment extends Fragment {
        public DummySectionFragment() {
        public static final String ARG_SECTION_NUMBER = "section_number";
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            TextView textView = new TextView(getActivity());
            Bundle args = getArguments();
            return textView;

Layout: activity_mainactivity.xml:

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    tools:context=".Navigation" >

    This title strip will display the currently visible page title, as well as the page
    titles for adjacent pages.

        android:textColor="#fff" />




About Gokul

I am very much interested in android and Wicket framework. A core android developer and working in android native app development and responsive web mobile design. I have also worked in wicket fame work and java web development. I will keep on updating you about android and wicket framework and answer your query.

%d bloggers like this: