Example usage for android.support.v4.app FragmentManager findFragmentByTag

List of usage examples for android.support.v4.app FragmentManager findFragmentByTag

Introduction

In this page you can find the example usage for android.support.v4.app FragmentManager findFragmentByTag.

Prototype

public abstract Fragment findFragmentByTag(String tag);

Source Link

Document

Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction.

Usage

From source file:com.nextgis.woody.activity.MainActivity.java

protected void createNormalView() {
    ILayer layer = mMap.getLayerByName(Constants.KEY_MAIN);
    if (null == layer)
        return;// ww w  .jav a 2s.  c o m

    ILayerView layerView = (ILayerView) layer;
    layerView.setRenderer(new TreeRenderer((Layer) layer));

    //PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    setContentView(R.layout.activity_main);
    setToolbar(R.id.main_toolbar);
    setTitle(getText(R.string.app_name));

    findViewById(R.id.add_tree).setOnClickListener(this);

    FragmentManager fm = getSupportFragmentManager();
    MapFragment mapFragment = (MapFragment) fm.findFragmentByTag(Constants.FRAGMENT_MAP);

    if (mapFragment == null)
        mapFragment = new MapFragment();

    TreeDetailsFragment treeDetailsFragment = (TreeDetailsFragment) fm
            .findFragmentByTag(Constants.FRAGMENT_TREE_DETAILS);

    if (treeDetailsFragment == null)
        treeDetailsFragment = new TreeDetailsFragment();

    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.map_frame, mapFragment, Constants.FRAGMENT_MAP);
    ft.replace(R.id.tree_details, treeDetailsFragment, Constants.FRAGMENT_TREE_DETAILS);
    ft.commit();

    hideTreeDetails();
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorFragment.java

private void showFormulaEditorListFragment(String tag, int actionbarResId) {
    FragmentManager fragmentManager = ((FragmentActivity) context).getSupportFragmentManager();
    Fragment fragment = fragmentManager.findFragmentByTag(tag);

    if (fragment == null) {
        fragment = new FormulaEditorListFragment();
        Bundle bundle = new Bundle();
        bundle.putString(FormulaEditorListFragment.ACTION_BAR_TITLE_BUNDLE_ARGUMENT,
                context.getString(actionbarResId));
        bundle.putString(FormulaEditorListFragment.FRAGMENT_TAG_BUNDLE_ARGUMENT, tag);
        fragment.setArguments(bundle);/*from  w w  w.  j  av a 2s .c  o  m*/
        fragmentManager.beginTransaction().add(R.id.script_fragment_container, fragment, tag).commit();
    }
    ((FormulaEditorListFragment) fragment).showFragment(context);
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorFragment.java

private void showFormulaEditorScriptListFragment(String tag, int actionbarResId) {
    FragmentManager fragmentManager = ((FragmentActivity) context).getSupportFragmentManager();
    Fragment fragment = fragmentManager.findFragmentByTag(tag);

    if (fragment == null) {
        fragment = new FormulaEditorScriptListFragment();
        Bundle bundle = new Bundle();
        bundle.putString(FormulaEditorScriptListFragment.ACTION_BAR_TITLE_BUNDLE_ARGUMENT,
                context.getString(actionbarResId));
        bundle.putString(FormulaEditorScriptListFragment.FRAGMENT_TAG_BUNDLE_ARGUMENT, tag);
        fragment.setArguments(bundle);/*w w w  .j  a va 2s  . c o m*/
        fragmentManager.beginTransaction().add(R.id.script_fragment_container, fragment, tag).commit();
    }
    ((FormulaEditorScriptListFragment) fragment).showFragment(context);
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorFragment.java

private void showFormulaEditorVariableListFragment(String tag, int actionbarResId) {
    FragmentManager fragmentManager = ((FragmentActivity) context).getSupportFragmentManager();
    Fragment fragment = fragmentManager.findFragmentByTag(tag);

    if (fragment == null) {
        fragment = new FormulaEditorVariableListFragment();
        Bundle bundle = new Bundle();
        bundle.putString(FormulaEditorVariableListFragment.ACTION_BAR_TITLE_BUNDLE_ARGUMENT,
                context.getString(actionbarResId));
        bundle.putString(FormulaEditorVariableListFragment.FRAGMENT_TAG_BUNDLE_ARGUMENT, tag);
        fragment.setArguments(bundle);//  w  w w.j av  a 2 s  .  com
        fragmentManager.beginTransaction().add(R.id.script_fragment_container, fragment, tag).commit();
    }
    ((FormulaEditorVariableListFragment) fragment).setAddButtonListener(getActivity());
    ((FormulaEditorVariableListFragment) fragment).showFragment(context);
}

From source file:com.christophergs.mbientbasic.NavigationActivity.java

public void onClearButtonPressed(int position) {
    Log.i(TAG, String.format("CLEAR TEST: %d", position));
    FragmentManager fragmentManager = getSupportFragmentManager();
    BothFragment f1 = (BothFragment) fragmentManager
            .findFragmentByTag("com.christophergs.mbientbasic.BothFragment");
    GyroFragmentNew f2 = (GyroFragmentNew) fragmentManager
            .findFragmentByTag("com.christophergs.mbientbasic.GyroFragmentNew");
    f1.refreshChart(true);//from   w  w w  .j a v a 2 s .  c o  m
    f2.refreshChart(true);

}

From source file:com.nextgis.woody.activity.MainActivity.java

protected void createAccountView() {
    FragmentManager fm = getSupportFragmentManager();
    LoginFragment ngwLoginFragment = (LoginFragment) fm.findFragmentByTag(Constants.FRAGMENT_LOGIN);

    if (ngwLoginFragment == null)
        ngwLoginFragment = new LoginFragment();

    FacebookCallback<LoginResult> callback = new FacebookCallback<LoginResult>() {
        @Override//from   ww w  . j a v  a  2  s .c o  m
        public void onSuccess(LoginResult loginResult) {
            getFBUserData(loginResult);
        }

        @Override
        public void onCancel() {
            Toast.makeText(MainActivity.this, R.string.canceled, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(FacebookException exception) {
            Toast.makeText(MainActivity.this, R.string.error_auth, Toast.LENGTH_SHORT).show();
        }
    };

    ngwLoginFragment.setCallback(callback);
    ((LinearLayout) findViewById(R.id.login_frame)).removeAllViews();
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.login_frame, ngwLoginFragment, Constants.FRAGMENT_LOGIN);
    ft.commitAllowingStateLoss();
    ngwLoginFragment.setForNewAccount(true);
    ngwLoginFragment.setOnAddAccountListener(this);
    ngwLoginFragment.setUrlText(SettingsConstants.SITE_URL);
}

From source file:com.filemanager.free.utils.MainActivityHelper.java

public void search(final String input) {
    TabFragment tabFragment = mainActivity.getFragment();
    if (tabFragment == null)
        return;//from  ww w  .j a  va  2 s  .  co m
    final Main ma = (Main) tabFragment.getTab();
    final String fpath = ma.CURRENT_PATH;
    if (input.length() == 0) {
        return;
    }
    SEARCH_TEXT = input;
    mainActivity.mainFragment = (Main) mainActivity.getFragment().getTab();
    FragmentManager fm = mainActivity.getSupportFragmentManager();
    SearchAsyncHelper fragment = (SearchAsyncHelper) fm.findFragmentByTag(MainActivity.TAG_ASYNC_HELPER);

    if (fragment != null) {

        if (fragment.mSearchTask.getStatus() == AsyncTask.Status.RUNNING) {

            fragment.mSearchTask.cancel(true);
        }
        fm.beginTransaction().remove(fragment).commit();
    }

    addSearchFragment(fm, new SearchAsyncHelper(), fpath, input, ma.openMode, ma.ROOT_MODE);
    /*final MaterialDialog.Builder a = new MaterialDialog.Builder( mainActivity);
    a.title(R.string.search);
    a.input(utils.getString(mainActivity, R.string.enterfile), "", true, new MaterialDialog
        .InputCallback() {
    @Override
    public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {
    }
    });
    if ( mainActivity.theme1 == 1) a.theme(Theme.DARK);
    a.negativeText(R.string.cancel);
    a.positiveText(R.string.search);
    a.widgetColor(Color.parseColor(mainActivity.fabskin));
    a.positiveColor(Color.parseColor(mainActivity.fabskin));
    a.negativeColor(Color.parseColor(mainActivity.fabskin));
    a.onPositive(new MaterialDialog.SingleButtonCallback() {
    @Override
    public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
        materialDialog.dismiss();
        //String a = materialDialog.getInputEditText().getText().toString();
            
            
    }
    });
    MaterialDialog b = a.build();
    if (ma.openMode==2) b.getActionButton(DialogAction.POSITIVE).setEnabled(false);
    b.show();*/
}

From source file:com.nextgis.woody.activity.MainActivity.java

public void showTreeDetails(Feature treeFeature) {
    FrameLayout fl = (FrameLayout) findViewById(R.id.tree_details);
    if (fl.getVisibility() == View.GONE) {
        // hide fab
        findViewById(R.id.add_tree).setVisibility(View.GONE);
        // show details fragment
        fl.setVisibility(View.VISIBLE);
        // fill fragment with data
    }//from   w  w  w . j  av a2  s.c  o m

    FragmentManager fm = getSupportFragmentManager();

    TreeDetailsFragment treeDetailsFragment = (TreeDetailsFragment) fm
            .findFragmentByTag(Constants.FRAGMENT_TREE_DETAILS);
    treeDetailsFragment.fill(treeFeature);

    MapFragment mapFragment = (MapFragment) fm.findFragmentByTag(Constants.FRAGMENT_MAP);
    GeoPoint pt = (GeoPoint) treeFeature.getGeometry();
    mapFragment.setCenter(pt);
}

From source file:com.example.de.taomi2.mediachooser.activity.HomeFragmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_home_media_chooser);

    headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar);
    headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar);
    headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView);
    headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView);
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);

    mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent);
    headerBarBack.setOnClickListener(clickListener);
    headerBarCamera.setOnClickListener(clickListener);
    headerBarDone.setOnClickListener(clickListener);

    if (!MediaChooserConstants.showCameraVideo) {
        headerBarCamera.setVisibility(View.GONE);
    }//  ww  w.  j av  a2s.  com

    if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) {

        if (getIntent().getBooleanExtra("image", false)) {
            headerBarTitle.setText(getResources().getString(R.string.image));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));

            headerBarCamera.setTag(getResources().getString(R.string.image));

            Bundle bundle = new Bundle();
            bundle.putString("name", getIntent().getStringExtra("name"));
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab1")
                            .setIndicator(getResources().getString(R.string.images_tab) + "     "),
                    ImageFragment.class, bundle);

        } else {
            headerBarTitle.setText(getResources().getString(R.string.video));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
            headerBarCamera.setTag(getResources().getString(R.string.video));

            Bundle bundle = new Bundle();
            bundle.putString("name", getIntent().getStringExtra("name"));
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab2")
                            .setIndicator(getResources().getString(R.string.videos_tab) + "      "),
                    VideoFragment.class, bundle);
        }
    } else {

        if (MediaChooserConstants.showVideo) {
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab2")
                            .setIndicator(getResources().getString(R.string.videos_tab) + "      "),
                    VideoFragment.class, null);
        }

        if (MediaChooserConstants.showImage) {
            headerBarTitle.setText(getResources().getString(R.string.image));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));
            headerBarCamera.setTag(getResources().getString(R.string.image));

            mTabHost.addTab(
                    mTabHost.newTabSpec("tab1")
                            .setIndicator(getResources().getString(R.string.images_tab) + "      "),
                    ImageFragment.class, null);
        }

        if (MediaChooserConstants.showVideo) {
            headerBarTitle.setText(getResources().getString(R.string.video));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
            headerBarCamera.setTag(getResources().getString(R.string.video));
        }
    }

    for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {

        TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
        if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) {

            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams();
            params.addRule(RelativeLayout.CENTER_HORIZONTAL);
            params.addRule(RelativeLayout.CENTER_VERTICAL);
            params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
            params.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
            textView.setLayoutParams(params);

        } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams();
            params.gravity = Gravity.CENTER;
            textView.setLayoutParams(params);
        }
        textView.setTextColor(getResources().getColor(R.color.tabs_title_color));
        textView.setTextSize(convertDipToPixels(10));

    }

    if ((mTabHost.getTabWidget().getChildAt(0) != null)) {
        ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                .setTextColor(Color.WHITE);
    }

    if ((mTabHost.getTabWidget().getChildAt(1) != null)) {
        ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
    }

    mTabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {

            android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
            ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1");
            VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2");
            android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

            if (tabId.equalsIgnoreCase("tab1")) {

                headerBarTitle.setText(getResources().getString(R.string.image));
                setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));
                headerBarCamera.setTag(getResources().getString(R.string.image));

                if (imageFragment != null) {

                    if (videoFragment != null) {
                        fragmentTransaction.hide(videoFragment);
                    }
                    fragmentTransaction.show(imageFragment);
                }
                ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                        .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
                ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                        .setTextColor(Color.WHITE);

            } else {
                headerBarTitle.setText(getResources().getString(R.string.video));
                setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
                headerBarCamera.setTag(getResources().getString(R.string.video));

                if (videoFragment != null) {

                    if (imageFragment != null) {
                        fragmentTransaction.hide(imageFragment);
                    }

                    fragmentTransaction.show(videoFragment);
                    if (videoFragment.getAdapter() != null) {
                        videoFragment.getAdapter().notifyDataSetChanged();
                    }
                }
                ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                        .setTextColor(Color.WHITE);
                ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                        .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
            }

            fragmentTransaction.commit();
        }
    });

    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams();
    params.height = convertDipToPixels(40);
    params.width = convertDipToPixels(40);
    headerBarCamera.setLayoutParams(params);
    headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE);
    headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15),
            convertDipToPixels(15));

}

From source file:com.learnncode.mediachooser.activity.HomeFragmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_home_media_chooser);

    headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar);
    headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar);
    headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView);
    headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView);
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);

    mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent);
    headerBarBack.setOnClickListener(clickListener);
    headerBarCamera.setOnClickListener(clickListener);
    headerBarDone.setOnClickListener(clickListener);

    if (!MediaChooserConstants.showCameraVideo) {
        headerBarCamera.setVisibility(View.GONE);
    }//from ww  w  . j  a va 2  s . c  o  m

    if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) {

        if (getIntent().getBooleanExtra("image", false)) {
            headerBarTitle.setText(getResources().getString(R.string.image));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));

            headerBarCamera.setTag(getResources().getString(R.string.image));

            Bundle bundle = new Bundle();
            bundle.putString("name", getIntent().getStringExtra("name"));
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab1")
                            .setIndicator(getResources().getString(R.string.images_tab) + "     "),
                    ImageFragment.class, bundle);

        } else {
            headerBarTitle.setText(getResources().getString(R.string.video));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
            headerBarCamera.setTag(getResources().getString(R.string.video));

            Bundle bundle = new Bundle();
            bundle.putString("name", getIntent().getStringExtra("name"));
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab2")
                            .setIndicator(getResources().getString(R.string.videos_tab) + "      "),
                    VideoFragment.class, bundle);
        }
    } else {

        if (MediaChooserConstants.showVideo) {
            mTabHost.addTab(
                    mTabHost.newTabSpec("tab2")
                            .setIndicator(getResources().getString(R.string.videos_tab) + "      "),
                    VideoFragment.class, null);
        }

        if (MediaChooserConstants.showImage) {
            headerBarTitle.setText(getResources().getString(R.string.image));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));
            headerBarCamera.setTag(getResources().getString(R.string.image));

            mTabHost.addTab(
                    mTabHost.newTabSpec("tab1")
                            .setIndicator(getResources().getString(R.string.images_tab) + "      "),
                    ImageFragment.class, null);
        }

        if (MediaChooserConstants.showVideo) {
            headerBarTitle.setText(getResources().getString(R.string.video));
            setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
            headerBarCamera.setTag(getResources().getString(R.string.video));
        }
    }

    for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {

        TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
        if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) {

            RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) textView
                    .getLayoutParams();
            params.addRule(RelativeLayout.CENTER_HORIZONTAL);
            params.addRule(RelativeLayout.CENTER_VERTICAL);
            params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
            params.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
            textView.setLayoutParams(params);

        } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
            LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) textView
                    .getLayoutParams();
            params.gravity = Gravity.CENTER;
            textView.setLayoutParams(params);
        }
        textView.setTextColor(getResources().getColor(R.color.tabs_title_color));
        textView.setTextSize(convertDipToPixels(10));

    }

    if ((mTabHost.getTabWidget().getChildAt(0) != null)) {
        ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                .setTextColor(Color.WHITE);
    }

    if ((mTabHost.getTabWidget().getChildAt(1) != null)) {
        ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
    }

    mTabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {

            android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
            ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1");
            VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2");
            android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

            if (tabId.equalsIgnoreCase("tab1")) {

                headerBarTitle.setText(getResources().getString(R.string.image));
                setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button));
                headerBarCamera.setTag(getResources().getString(R.string.image));

                if (imageFragment != null) {

                    if (videoFragment != null) {
                        fragmentTransaction.hide(videoFragment);
                    }
                    fragmentTransaction.show(imageFragment);
                }
                ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                        .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
                ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                        .setTextColor(Color.WHITE);

            } else {
                headerBarTitle.setText(getResources().getString(R.string.video));
                setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button));
                headerBarCamera.setTag(getResources().getString(R.string.video));

                if (videoFragment != null) {

                    if (imageFragment != null) {
                        fragmentTransaction.hide(imageFragment);
                    }

                    fragmentTransaction.show(videoFragment);
                    if (videoFragment.getAdapter() != null) {
                        videoFragment.getAdapter().notifyDataSetChanged();
                    }
                }
                ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title)))
                        .setTextColor(Color.WHITE);
                ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title)))
                        .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color));
            }

            fragmentTransaction.commit();
        }
    });

    RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) headerBarCamera
            .getLayoutParams();
    params.height = convertDipToPixels(40);
    params.width = convertDipToPixels(40);
    headerBarCamera.setLayoutParams(params);
    headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE);
    headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15),
            convertDipToPixels(15));

}