Example usage for android.support.v4.view ViewPager ViewPager

List of usage examples for android.support.v4.view ViewPager ViewPager

Introduction

In this page you can find the example usage for android.support.v4.view ViewPager ViewPager.

Prototype

public ViewPager(Context context) 

Source Link

Usage

From source file:com.negaheno.ui.Components.EmojiView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(getContext());
        if (AndroidUtilities.isTablet()) {
            gridView.setColumnWidth(AndroidUtilities.dp(60));
        } else {//from www . j  a v  a  2s . co  m
            gridView.setColumnWidth(AndroidUtilities.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(localEmojiGridAdapter);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999);
        adapters.add(localEmojiGridAdapter);
    }

    setBackgroundColor(0xff222222);
    pager = new ViewPager(getContext());
    pager.setAdapter(new EmojiPagesAdapter());
    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorColor(0xff33b5e5);
    tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f));
    tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f));
    tabs.setUnderlineColor(0x66000000);
    tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (EmojiView.this.listener != null) {
                EmojiView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT));
    recentsWrap = new FrameLayout(getContext());
    recentsWrap.addView(views.get(0));
    TextView localTextView = new TextView(getContext());
    localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    localTextView.setTextSize(18.0f);
    localTextView.setTextColor(-7829368);
    localTextView.setGravity(17);
    recentsWrap.addView(localTextView);
    views.get(0).setEmptyView(localTextView);
    addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f)));
    addView(pager);
    loadRecents();
    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }

    updateColors(tabs);
}

From source file:me.cpwc.nibblegram.ui.Components.EmojiView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(getContext());
        if (AndroidUtilities.isTablet()) {
            gridView.setColumnWidth(AndroidUtilities.dp(60));
        } else {// w ww.j  a v  a 2  s  . c  om
            gridView.setColumnWidth(AndroidUtilities.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(localEmojiGridAdapter);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999);
        adapters.add(localEmojiGridAdapter);
    }

    setBackgroundColor(0xff222222);
    pager = new ViewPager(getContext());
    pager.setAdapter(new EmojiPagesAdapter());
    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorColor(0xff33b5e5);
    tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f));
    tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f));
    tabs.setUnderlineColor(0x66000000);
    tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (EmojiView.this.listener != null) {
                EmojiView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT));
    recentsWrap = new FrameLayout(getContext());
    recentsWrap.addView(views.get(0));
    TextView localTextView = new TextView(getContext());
    localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    localTextView.setTextSize(18.0f);
    localTextView.setTextColor(-7829368);
    localTextView.setGravity(17);
    recentsWrap.addView(localTextView);
    views.get(0).setEmptyView(localTextView);
    addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f)));
    addView(pager);
    loadRecents();
    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:hoahong.facebook.messenger.ui.EmojiView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(getContext());
        if (Utils.isTablet()) {
            gridView.setColumnWidth(Utils.dp(60));
        } else {//from   ww w  . j  a v  a2s.  c o  m
            gridView.setColumnWidth(Utils.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(localEmojiGridAdapter);
        adapters.add(localEmojiGridAdapter);
    }

    setBackgroundDrawable(
            new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 }));
    pager = new ViewPager(getContext());
    pager.setAdapter(new EmojiPagesAdapter());
    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorColor(0xff33b5e5);
    tabs.setIndicatorHeight(Utils.dpf(2.0f));
    tabs.setUnderlineHeight(Utils.dpf(2.0f));
    tabs.setUnderlineColor(0x66000000);
    tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (EmojiView.this.listener != null) {
                EmojiView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LinearLayout.LayoutParams(Utils.dp(61), LayoutParams.MATCH_PARENT));
    recentsWrap = new FrameLayout(getContext());
    recentsWrap.addView(views.get(0));
    TextView localTextView = new TextView(getContext());
    localTextView.setText("No recent");
    localTextView.setTextSize(18.0f);
    localTextView.setTextColor(-7829368);
    localTextView.setGravity(17);
    recentsWrap.addView(localTextView);
    views.get(0).setEmptyView(localTextView);
    addView(localLinearLayout, new LinearLayout.LayoutParams(-1, Utils.dpf(48.0f)));
    addView(pager);
    loadRecents();
    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:org.telegram.ui.Views.EmojiView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(getContext());
        if (AndroidUtilities.isTablet()) {
            gridView.setColumnWidth(AndroidUtilities.dp(60));
        } else {/*w  w  w  .jav a 2s.co  m*/
            gridView.setColumnWidth(AndroidUtilities.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(localEmojiGridAdapter);
        adapters.add(localEmojiGridAdapter);
    }

    setBackgroundDrawable(
            new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 }));
    pager = new ViewPager(getContext());
    pager.setAdapter(new EmojiPagesAdapter());
    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorColor(0xff33b5e5);
    tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f));
    tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f));
    tabs.setUnderlineColor(0x66000000);
    tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (EmojiView.this.listener != null) {
                EmojiView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT));
    recentsWrap = new FrameLayout(getContext());
    recentsWrap.addView(views.get(0));
    TextView localTextView = new TextView(getContext());
    localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    localTextView.setTextSize(18.0f);
    localTextView.setTextColor(-7829368);
    localTextView.setGravity(17);
    recentsWrap.addView(localTextView);
    views.get(0).setEmptyView(localTextView);
    addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dpf(48.0f)));
    addView(pager);
    loadRecents();
    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:com.ab.view.sliding.AbBottomTabView.java

/**
 * Instantiates a new ab bottom tab view.
 *
 * @param context the context/*from  www  .  j  ava 2s  .  c o  m*/
 * @param attrs the attrs
 */
public AbBottomTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1));
    addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    //Tab?
    tabItemList = new ArrayList<AbTabItemView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();
    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbBottomTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

}

From source file:com.dreamchen.useful.mouserace.view.sliding.AbBottomTabView.java

/**
 * Instantiates a new ab bottom tab view.
 *
 * @param context the context/*from www  .java  2s. c o m*/
 * @param attrs the attrs
 */
public AbBottomTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1));
    addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();
    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbBottomTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

}

From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothFixTabView.java

/**
 * Instantiates a new ab sliding smooth fix tab view.
 *
 * @param context the context/*from  w w  w . j a  v  a  2  s  .  c  o m*/
 * @param attrs the attrs
 */
public ESSlidingSmoothFixTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabLayout, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        ESLogUtil.e(ESSlidingSmoothFixTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    DisplayMetrics mDisplayMetrics = ESAppUtil.getDisplayMetrics(context);
    mWidth = mDisplayMetrics.widthPixels;

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java

/**
 * Instantiates a new ab sliding smooth fix tab view.
 *
 * @param context the context/* ww  w .  ja va  2s  .  c o m*/
 * @param attrs the attrs
 */
public AbSlidingSmoothFixTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabLayout, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbSlidingSmoothFixTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context);
    mWidth = mDisplayMetrics.widthPixels;

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

}

From source file:com.almalence.opencam.ui.AlmalenceStore.java

public void showStore() {
    LayoutInflater inflater = LayoutInflater.from(MainScreen.getInstance());
    List<RelativeLayout> pages = new ArrayList<RelativeLayout>();

    // <!-- -+-
    final boolean unlocked = false;
    //-+- -->/* w  ww  .  ja  v  a2 s.  c o  m*/
    /* <!-- +++
    final boolean unlocked = true; 
     +++ --> */

    // page 1
    RelativeLayout page = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_pager_fragment, null);
    initStoreList();

    RelativeLayout store = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_store, null);
    final ImageView imgStoreNext = (ImageView) store.findViewById(R.id.storeWhatsNew);
    GridView gridview = (GridView) store.findViewById(R.id.storeGrid);
    gridview.setAdapter(storeAdapter);

    if (!unlocked) {
        page.addView(store);
        pages.add(page);
    }

    // page 2
    page = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_pager_fragment, null);
    RelativeLayout features = (RelativeLayout) inflater.inflate(R.layout.gui_almalence_features, null);
    final ImageView imgFeaturesPrev = (ImageView) features.findViewById(R.id.storeWhatsNew);
    imgFeaturesPrev.setVisibility(View.INVISIBLE);
    WebView wv = (WebView) features.findViewById(R.id.text_features);
    wv.loadUrl("file:///android_asset/www/features.html");

    page.addView(features);
    pages.add(page);

    SamplePagerAdapter pagerAdapter = new SamplePagerAdapter(pages);
    final ViewPager viewPager = new ViewPager(MainScreen.getInstance());
    viewPager.setAdapter(pagerAdapter);
    if (!unlocked)
        viewPager.setCurrentItem(0);
    else
        viewPager.setCurrentItem(1);
    viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            switch (position) {
            case 0:
                // 0
                imgStoreNext.setVisibility(View.VISIBLE);
                // 1
                imgFeaturesPrev.setVisibility(View.INVISIBLE);
                break;
            case 1:
                // 0
                imgStoreNext.setVisibility(View.INVISIBLE);
                // 1
                if (!unlocked)
                    imgFeaturesPrev.setVisibility(View.VISIBLE);
                else
                    imgFeaturesPrev.setVisibility(View.INVISIBLE);
                break;
            default:
                break;
            }
        }
    });

    imgStoreNext.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            viewPager.setCurrentItem(1);
        }
    });

    imgFeaturesPrev.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            viewPager.setCurrentItem(0);
        }
    });

    guiView.findViewById(R.id.buttonGallery).setEnabled(false);
    guiView.findViewById(R.id.buttonShutter).setEnabled(false);
    guiView.findViewById(R.id.buttonSelectMode).setEnabled(false);

    PluginManager.getInstance().sendMessage(ApplicationInterface.MSG_BROADCAST,
            ApplicationInterface.MSG_CONTROL_LOCKED);

    MainScreen.getGUIManager().lockControls = true;

    // <!-- -+-
    if (MainScreen.getInstance().showPromoRedeemed) {
        Toast.makeText(MainScreen.getInstance(),
                "The promo code has been successfully redeemed. All PRO-Features are unlocked",
                Toast.LENGTH_LONG).show();
        MainScreen.getInstance().showPromoRedeemed = false;
    }
    if (MainScreen.getInstance().showPromoRedeemedJulius) {
        Toast.makeText(MainScreen.getInstance(),
                MainScreen.getInstance().getResources().getString(R.string.promoRedeemedJulius),
                Toast.LENGTH_LONG).show();
        MainScreen.getInstance().showPromoRedeemedJulius = false;
    }
    //-+- -->

    final RelativeLayout pagerLayout = ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayout));
    pagerLayout.addView(viewPager);

    final RelativeLayout pagerLayoutMain = ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayoutMain));
    pagerLayoutMain.setVisibility(View.VISIBLE);
    pagerLayoutMain.bringToFront();

    // We need this timer, to show store on top, after we return from google
    // play.
    // In MainScreen there is timer, which brings main buttons on top,
    // after MainScreen activity resumed.
    // So this timer "blocks" timer from MainScreen if we want to show
    // store.
    new CountDownTimer(600, 10) {
        public void onTick(long millisUntilFinished) {
            pagerLayoutMain.bringToFront();
        }

        public void onFinish() {
            pagerLayoutMain.bringToFront();
        }
    }.start();
}

From source file:org.monospace.smsfilter.MainActivity.java

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

    mTabs = new TabSet(NUM_TABS);
    mTabs.add(TAB_SMS, R.string.tab_sms_list, SMSListFragment.class);
    mTabs.add(TAB_FILTER, R.string.tab_filter_list, FilterListFragment.class);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);

    ViewPager pager = new ViewPager(this);
    pager.setId(R.id.main_pager);//from  www.j  a  v  a2  s .  c o m

    TabHelper helper = new TabHelper(this, pager);
    pager.setAdapter(helper);
    pager.setOnPageChangeListener(helper);

    for (TabSet.Tab t : mTabs) {
        Tab tab = actionBar.newTab().setText(t.textId).setTabListener(helper);
        actionBar.addTab(tab);
    }

    setContentView(pager);

    mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            SMSListFragment fragment = (SMSListFragment) mTabs.getItem(TAB_SMS);
            fragment.refresh();
        }
    };

    registerReceiver(mReceiver, new IntentFilter("org.monospace.smsfilter.NEW_BLOCKED_SMS"));
}