Example usage for android.view Window FEATURE_ACTION_BAR

List of usage examples for android.view Window FEATURE_ACTION_BAR

Introduction

In this page you can find the example usage for android.view Window FEATURE_ACTION_BAR.

Prototype

int FEATURE_ACTION_BAR

To view the source code for android.view Window FEATURE_ACTION_BAR.

Click Source Link

Document

Flag for enabling the Action Bar.

Usage

From source file:main.MainActivity.java

@Override
protected void onCreate(Bundle b) {
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    super.onCreate(b);
    setContentView(R.layout.activity_main);

    startService(new Intent(this, SensorListener.class));

    initialStep = 0;// w  w  w.  j a  v a2 s.com
    firstTime = true;
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    ButterKnife.inject(this);
    setSupportActionBar(toolbar);
    adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    // tabs.setDistributeEvenly(true);
    tabs.setViewPager(pager);
    final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    pager.setOffscreenPageLimit(3);
    pager.setCurrentItem(0);
    tabs.setBackgroundColor(getResources().getColor(R.color.green));
    tabs.setIndicatorColor(R.color.tabsScrollColor);
    tabs.setTextColor(getResources().getColor(R.color.text_shadow_white));
    //  getSupportActionBar().setIcon(R.drawable.icon2);
    tabs.setIndicatorColorResource(R.color.tabsScrollColor);

}

From source file:com.univ.helsinki.app.MainActivity.java

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

    if (FeedResource.getInstance().getSharedPrefs().getBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH,
            false)) {// w  w  w. j  a  v a  2s . co m

        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
        getActionBar().hide();

        hideTitle();
    }

    setContentView(R.layout.activity_main);

    splashLayout = (ViewGroup) findViewById(R.id.splashLayout);

    if (FeedResource.getInstance().getSharedPrefs().getBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH,
            false)) {
        // record the fact that the app has been started at least once
        FeedResource.getInstance().getSharedPrefs().edit()
                .putBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH, false).commit();

        final ViewGroup splashLayout = (ViewGroup) findViewById(R.id.splashLayout);

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                activateSplashScreen(splashLayout);
            }
        }, Constant.SPLASH_SCREEN_TIME_OUT);

    } else {
        splashLayout.setVisibility(View.GONE);
    }

    FeedResource.getInstance().inti(this);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    mSensorFeedAdapter = new SensorFeedAdapter(this);

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
            switch (position) {
            case 0: {
                // on focus when first fragment
                //Toast.makeText(getApplicationContext(), "onPageSelected :" + position, Toast.LENGTH_SHORT).show();

                List<SensorFeed> mtempAllowedSensorFeedList = new ArrayList<SensorFeed>();
                // update the list over here.. to avoid empty shell
                for (SensorFeed sensor : FeedResource.getInstance().getSensorFeedList()) {

                    boolean isChecked = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
                            .getBoolean(sensor.getSensorKey(), false);

                    if (isChecked)
                        mtempAllowedSensorFeedList.add(sensor);
                }
                // update the list with new created list
                mSensorFeedAdapter.setFeedList(mtempAllowedSensorFeedList);

            }
                break;
            }// switch ends
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.af.synapse.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    startTime = System.nanoTime();

    Utils.mainActivity = this;
    Utils.density = getResources().getDisplayMetrics().density;
    Utils.imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    Synapse.openExecutor();//from   w w w .  ja  va2 s .c  om
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    Settings.setWallpaper(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);

        if (Settings.getAppTheme() == Settings.Theme.TRANSLUCENT_DARK) {
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setStatusBarTintResource(R.drawable.black_gradient_270);
        }

        if (Utils.hasSoftKeys(getWindowManager())) {
            tintManager.setNavigationBarTintEnabled(true);
            tintManager.setNavigationBarTintResource(R.drawable.black_gradient_90);
        }
    }

    getActionBar().hide();

    setPaddingDimensions();
    setContentView(R.layout.activity_loading);

    if (!Utils.appStarted)
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    super.onCreate(fragments == null ? null : savedInstanceState);

    if (fragments == null) {
        if (Synapse.currentEnvironmentState != Synapse.environmentState.VALID_ENVIRONMENT) {
            findViewById(R.id.initialProgressBar).setVisibility(View.INVISIBLE);
            switch (Synapse.currentEnvironmentState) {
            case ROOT_FAILURE:
                ((TextView) findViewById(R.id.initialText)).setText(R.string.initial_no_root);
                break;
            case UCI_FAILURE:
                ((TextView) findViewById(R.id.initialText)).setText(R.string.initial_no_uci);
                break;
            case JSON_FAILURE:
                ((TextView) findViewById(R.id.initialText)).setText(R.string.initial_json_parse);
            }

            return;
        }
    }

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    /**
     *  The UI building continues in buildFragment after fragment generation, or if
     *  the fragments are already live, continue here.
     */

    if (fragmentsDone.get() == Utils.configSections.size())
        continueCreate();
}

From source file:com.example.administrator.myapplication2._3_HB._3_MainActivity.java

/*****************************************************
 *    Overrided methods//from   w w  w .  j  ava 2 s  .com
 ******************************************************/

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

    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    //----- System, Context
    mContext = this; //.getApplicationContext();
    mActivityHandler = new ActivityHandler();
    AppSettings.initializeAppSettings(mContext);

    setContentView(R.layout._3_activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the primary sections of the app.
    mFragmentManager = getSupportFragmentManager();
    mSectionsPagerAdapter = new FragmentAdapter(mFragmentManager, mContext, this, mActivityHandler);

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

    // When swiping between different sections, select the corresponding tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    // Setup views
    mImageBT = (ImageView) findViewById(R.id.status_title);
    mImageBT.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_invisible));
    mTextStatus = (TextView) findViewById(R.id.status_text);
    mTextStatus.setText(getResources().getString(R.string.bt_state_init));

    // Do data initialization after service started and binded
    doStartService();
}

From source file:com.klinker.android.twitter.ui.tweet_viewer.users_popup.ViewUsersPopup.java

public void setUpWindow() {

    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
            WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    // Params for the window.
    // You can easily set the alpha and the dim behind the window from here
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.alpha = 1.0f; // lower than one makes it more transparent
    params.dimAmount = .75f; // set it higher if you want to dim behind the window
    getWindow().setAttributes(params);//from w w  w . ja  v  a 2s  .  c  o  m

    // Gets the display size so that you can set the window to a percent of that
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    // You could also easily used an integer value from the shared preferences to set the percent
    if (height > width) {
        getWindow().setLayout((int) (width * .9), (int) (height * .8));
    } else {
        getWindow().setLayout((int) (width * .7), (int) (height * .8));
    }

}

From source file:com.android.gallery3d.app.Gallery.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.main);/*w  w  w  . ja  v a2  s  .  c  o m*/
    mActionBar = new GalleryActionBar(this);

    if (savedInstanceState != null) {
        getStateManager().restoreFromState(savedInstanceState);
    } else {
        initializeByIntent();
    }
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java

/**
 * {@inheritDoc}/*from   w  ww. jav a  2s.c  om*/
 */
@Override
public void onCreate(Bundle icicle) {
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "onCreate(" + icicle + ")");
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        requestWindowFeature(Window.FEATURE_ACTION_BAR);
    }
    super.onCreate(icicle);

    mAccountManager = AccountManager.get(this);
    if (BuildConfig.DEBUG) {
        Log.i(TAG, "loading data from Intent");
    }

    final Intent intent = getIntent();
    mUsername = intent.getStringExtra(EXTRA_USERNAME);
    mAuthtokenType = intent.getStringExtra(EXTRA_AUTHTOKEN_TYPE);
    mRequestNewAccount = mUsername == null;
    mConfirmCredentials = intent.getBooleanExtra(EXTRA_CONFIRMCREDENTIALS, false);

    if (BuildConfig.DEBUG) {
        Log.i(TAG, "    request new: " + mRequestNewAccount);
    }
    requestWindowFeature(Window.FEATURE_LEFT_ICON);

    final CharSequence appName = getAppName();

    // make the title based on the app name.
    setTitle(getString(R.string.login_title, appName));

    // TODO make this changeable. Maybe use fragments?
    setContentView(R.layout.login);
    // this is done this way, so the associated icon is managed in XML.
    try {
        getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON,
                getPackageManager().getActivityIcon(getComponentName()));
    } catch (final NameNotFoundException e) {
        e.printStackTrace();
    }

    mMessage = (TextView) findViewById(R.id.message);
    mUsernameEdit = (EditText) findViewById(R.id.username);
    mUsernameEdit.setHint(isEmailAddressLogin() ? R.string.auth_email_login_hint : R.string.auth_username_hint);
    mPasswordEdit = (EditText) findViewById(R.id.password);
    mPasswordEdit.setOnEditorActionListener(this);
    findViewById(R.id.login).setOnClickListener(this);
    findViewById(R.id.cancel).setOnClickListener(this);
    mRegisterButton = (Button) findViewById(R.id.register);
    mRegisterButton.setOnClickListener(this);
    final String regButton = getString(R.string.signup_text, appName);
    if (regButton.length() < 24) {
        mRegisterButton.setText(regButton);
    }

    ((TextView) findViewById(R.id.username_label)).setText(getString(R.string.username_label, appName));

    mUsernameEdit.setText(mUsername);

    // this will be unnecessary with fragments
    mAuthenticationTask = (AuthenticationTask) getLastNonConfigurationInstance();
    if (mAuthenticationTask != null) {
        mAuthenticationTask.attach(this);
    }
}

From source file:nf.frex.android.FrexActivity.java

/**
 * Called when the activity is first created.
 *///from  w  w w .ja v a  2  s .  c  om
@Override
public void onCreate(Bundle savedInstanceState) {
    //Log.d(TAG, "onCreate(savedInstanceState=" + savedInstanceState + ")");
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    if (PRE_SDK14) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // Fix: Frex to stop working on screen orientation changes (Android 2.3.x only)
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    } else {
        getActionBar().setBackgroundDrawable(new PaintDrawable(Color.argb(128, 0, 0, 0)));
    }

    view = new FractalView(this);
    setContentView(view);

    if (!tryReadingFrexDocIntent(getIntent())) {
        if (savedInstanceState != null) {
            view.restoreInstanceState(new BundlePropertySet(savedInstanceState));
        } else {
            PropertySet propertySet = (PropertySet) getLastNonConfigurationInstance();
            if (propertySet != null) {
                view.restoreInstanceState(propertySet);
            }
        }
    }
}

From source file:org.wheelmap.android.activity.MainSinglePaneActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_single_pane);

    appProperties = AppProperties.getInstance(WheelmapApp.getApp());
    Log.d(TAG, "onCreate");

    ActionBar actionbar = getSupportActionBar();
    if (actionbar != null) {
        actionbar.setHomeButtonEnabled(true);
        actionbar.setDisplayShowTitleEnabled(true);
        actionbar.setDisplayHomeAsUpEnabled(true);
    }/*from  w w w. j a  va2 s .co  m*/

    flipper = (ViewFlipper) findViewById(R.id.flipper);
    flipper.setDisplayedChild(0);

    FragmentManager.enableDebugLogging(true);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    View customNav = LayoutInflater.from(this).inflate(R.layout.actionbar, null);
    actionBar.setCustomView(customNav);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    mWorkerFragment = (CombinedWorkerFragment) fm.findFragmentByTag(CombinedWorkerFragment.TAG);
    if (mWorkerFragment == null) {
        mWorkerFragment = new CombinedWorkerFragment();
        t.add(mWorkerFragment, CombinedWorkerFragment.TAG);
    }

    mListFragment = (POIsListFragment) fm.findFragmentById(R.id.list_layout);
    if (mListFragment == null) {
        mListFragment = POIsListFragment.newInstance(false, true);
        t.add(R.id.list_layout, mListFragment, POIsListFragment.TAG);
    }

    mMapFragment = (POIsOsmdroidFragment) fm.findFragmentById(R.id.map_layout);
    if (mMapFragment == null) {
        mMapFragment = POIsOsmdroidFragment.newInstance(false, true);
        t.add(R.id.map_layout, mMapFragment, POIsOsmdroidFragment.TAG);
    }

    t.commit();

    if (savedInstanceState != null) {
        executeState(savedInstanceState);
    } else {
        executeDefaultInstanceState();
    }

    Bundle extras = getIntent().getExtras();
    if (extras.containsKey(Extra.MAP_MODE_ENGAGE)) {
        mapModeType = MapModeType.MAP_MODE_ENGAGE;
        MapActivityUtils.setWheelchairFilterToEngageMode(this);
    } else {
        mapModeType = MapModeType.MAP_MODE_NORMAL;
    }
}

From source file:com.first3.viz.ui.ActivityDelegate.java

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

    Bundle b = getIntent().getExtras();/*from   www  .ja v a2  s  . c o  m*/
    if (b != null) {
        mIntentTab = b.getInt(BUNDLE_LOAD_TAB);
    }

    if (BuildConfig.DEBUG) {
        Log.d("Viz running in debug mode");
    }

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.main);
    Log.d();

    mActionBar = this.getActionBar();
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mActionBar.setDisplayShowTitleEnabled(true);
    mActionBar.setDisplayShowHomeEnabled(true);

    mBrowserTab = mActionBar.newTab().setIcon(R.drawable.ic_action_tab_browser);
    mDownloadsTab = mActionBar.newTab().setIcon(R.drawable.ic_action_tab_downloads);
    mFavoritesTab = mActionBar.newTab().setIcon(R.drawable.ic_action_tab_favorites);
    mFileManagerTab = mActionBar.newTab().setIcon(R.drawable.ic_action_tab_filemanager);
    mSettingsTab = mActionBar.newTab().setIcon(R.drawable.ic_action_tab_settings);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, mActionBar, mViewPager);
    mTabsAdapter.addTab(mFileManagerTab, FileManager.class, null);
    mTabsAdapter.addTab(mFavoritesTab, Favorites.class, null);
    mTabsAdapter.addTab(mBrowserTab, Browser.class, null);
    mTabsAdapter.addTab(mDownloadsTab, Downloads.class, null);
    mTabsAdapter.addTab(mSettingsTab, Settings.class, null);

    getVideoPlayerFragment().addEventListener(new VideoPlayer.EventListener() {
        @Override
        public void onVideoCompleted() {
            switchToTabView();
        }

        @Override
        public void onVideoPaused() {
        }
    });

    updateUI();
    createDefaultDirectories();
    VersionChangeNotifier.getInstance().start(this);
}