Example usage for android.app ActionBar setTitle

List of usage examples for android.app ActionBar setTitle

Introduction

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

Prototype

public abstract void setTitle(@StringRes int resId);

Source Link

Document

Set the action bar's title.

Usage

From source file:org.floens.chan.ui.activity.BoardActivity.java

private void updateActionBarStateCallback() {
    final ActionBar actionBar = getActionBar();

    if (threadPane.isSlideable()) {
        if (threadPane.isOpen()) {
            int index = getBoardIndexNavigator(boardLoadable.board);

            if (index >= 0) {
                //                    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
                setActionBarListMode();/*from  w  w w  . j  av a  2 s  .c om*/
                actionBar.setTitle("");
            } else {
                actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
                String niceTitle = ChanApplication.getBoardManager().getBoardKey(boardLoadable.board);
                if (niceTitle == null) {
                    actionBar.setTitle("/" + boardLoadable.board + "/");
                } else {
                    actionBar.setTitle(niceTitle);
                }
            }

            actionBar.setHomeButtonEnabled(true);
            pinDrawerListener.setDrawerIndicatorEnabled(true);

            if (boardLoadable.isBoardMode())
                setShareUrl(ChanUrls.getBoardUrlDesktop(boardLoadable.board));
        } else {
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            actionBar.setTitle(threadLoadable.title);
            pinDrawerListener.setDrawerIndicatorEnabled(false);

            if (threadLoadable.isThreadMode())
                setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }

        actionBar.setDisplayHomeAsUpEnabled(true);
    } else {
        setActionBarListMode();
        //            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        pinDrawerListener.setDrawerIndicatorEnabled(true);
        actionBar.setTitle(threadLoadable.title);

        actionBar.setDisplayHomeAsUpEnabled(true);

        if (threadLoadable.isThreadMode())
            setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
    }

    actionBar.setDisplayShowTitleEnabled(true);

    invalidateOptionsMenu();
}

From source file:fm.krui.kruifm.StreamActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.stream_layout);

    // Instantiate class members
    prefManager = new PreferenceManager(this);
    favTrackManager = new FavoriteTrackManager(this);

    stationTag = getIntent().getIntExtra(KEY_STATION_TAG, -1);

    // Set ActionBar Title
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(getString(R.string.listen_sidebar));
    actionBar.setSubtitle(getActivitySubtitle(getIntent()));

    // FIXME: Move these to PreferenceManager after expanding its scope for cleaner code
    trackPrefs = this.getSharedPreferences(StreamService.PREFS_NAME, 0);

    // Instantiate broadcast receiver
    broadcastReceiver = new BroadcastReceiver() {
        @Override//  w w  w.  ja va2  s . co  m
        public void onReceive(Context context, Intent intent) {
            processBroadcastCommand(intent);
        }
    };

    // Retrieve player state to determine how to build this activity
    boolean playerState = prefManager.getPlayerState();

    // If audio is playing in StreamService, we don't want to rebuffer, and we want to restore the UI state from the cache.
    if (playerState) {
        restoreUIState();
    }

    // If audio is NOT playing, buffer and treat this launch like a clean startup.
    else {
        // Determine the URL we need to use to stream based on the station tag and quality preferences
        streamUrl = getStreamUrl(stationTag);
        Log.v(TAG, "streamUrl is now set to: " + streamUrl);

        // Perform initial configuration of audio server
        changeUrl(stationTag);

        // Begin buffering the audio
        startAudio((ImageView) this.findViewById(R.id.play_audio_imageview));
    }

    // Build play button listener
    final ImageView playButton = (ImageView) this.findViewById(R.id.play_audio_imageview);
    playButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            handleAudio(playButton);
        }
    });

    // Build volume seek bar listener
    // ** DISABLED FOR NOW -- This might be completely thrown out. **
    /*final SeekBar volumeSeekBar = (SeekBar)this.findViewById(R.id.volume_seekbar);
    volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            
    // When seek bar progress is changed, change the audio of the media player appropriately.
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        // Send new volume via intent? Will this be slow?
    }
            
    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    }
            
    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
    }
    }); */

    // Build settings button listener and apply it to settings icon and submit button
    View.OnClickListener flipListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Card flip animation which toggles between stream controls and settings views
            flipCard();
        }
    };

    final ImageView settingsButton = (ImageView) this.findViewById(R.id.stream_settings_imageview);
    final Button saveSettingsButton = (Button) this.findViewById(R.id.set_stream_settings_button);
    settingsButton.setOnClickListener(flipListener);
    saveSettingsButton.setOnClickListener(flipListener);

    // Build favorite button listener
    final ImageView favoriteButton = (ImageView) this.findViewById(R.id.stream_favorite_imageview);
    favoriteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (trackIsFavorite) {
                favoriteButton.setImageResource(R.drawable.star_unfilled_white);
                trackIsFavorite = false;
                removeTrackFromFavorites();
            } else {
                favoriteButton.setImageResource(R.drawable.star_filled_white);
                trackIsFavorite = true;
                addTrackToFavorites();
            }
        }
    });

    // Build settings switches
    final Switch streamQualitySwitch = (Switch) this.findViewById(R.id.stream_quality_switch);
    final Switch albumArtSwitch = (Switch) this.findViewById(R.id.stream_album_art_switch);

    // Set initial state of switches
    albumArtSwitch.setChecked(prefManager.getAlbumArtDownloadPreference());
    if (prefManager.getStreamQuality() == prefManager.HIGH_QUALITY) {
        streamQualitySwitch.setChecked(true);
    } else {
        streamQualitySwitch.setChecked(false);
    }

    // Assign listeners to switches
    streamQualitySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                prefManager.setStreamQuality(prefManager.HIGH_QUALITY);
                Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality());
            } else {
                prefManager.setStreamQuality(prefManager.LOW_QUALITY);
                Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality());
            }
            changeUrl(stationSpinnerPosition);
        }
    });

    albumArtSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                prefManager.setAlbumArtDownloadPreference(true);
                Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference());
            } else {
                prefManager.setAlbumArtDownloadPreference(false);
                Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference());
            }
        }
    });

    // ***** Old onCreate function starts here!
    // Initialize screen lock/wake receiver
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    BroadcastReceiver screenReceiver = new ScreenReceiver();

    // Attach it to this activity
    this.getApplicationContext().registerReceiver(screenReceiver, filter);

}

From source file:com.android.gpstest.GpsTestActivity.java

private void initActionBar(Bundle savedInstanceState) {
    // Set up the action bar.
    final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setTitle(getApplicationContext().getText(R.string.app_name));

    // If we don't have a large screen, set up the tabs using the ViewPager
    if (!mIsLargeScreen) {
        //  page adapter contains all the fragment registrations
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

        // When swiping between different sections, select the corresponding
        // tab. We can also use ActionBar.Tab#select() to do this if we have a
        // reference to the Tab.
        mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override//from w ww . j  av  a 2  s.  co m
            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. Also specify this Activity object, which implements
            // the TabListener interface, as the listener for when this tab is
            // selected.
            actionBar.addTab(
                    actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
        }
    }
}

From source file:com.tweetlanes.android.view.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDialog().build());
    //StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
    //StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());

    super.onCreate(savedInstanceState);

    AccountDescriptor account = getApp().getCurrentAccount();

    // Attempt at fixing a crash found in HomeActivity
    if (account == null) {
        Toast.makeText(getApplicationContext(), "No cached account found, restarting",
                Constant.DEFAULT_TOAST_DISPLAY_TIME).show();
        restartApp();/*from  w w  w . ja  v  a 2 s.c o  m*/
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setTitle(null);
    actionBar.setDisplayShowTitleEnabled(false);

    ArrayList<String> adapterList = new ArrayList<String>();
    ArrayList<AccountDescriptor> accounts = getApp().getAccounts();
    for (int i = 0; i < accounts.size(); i++) {
        AccountDescriptor acc = accounts.get(i);
        adapterList.add("@" + acc.getScreenName());
    }
    adapterList.add(getString(R.string.add_account));
    mAdapterStrings = adapterList.toArray(new String[adapterList.size()]);

    mSpinnerAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item,
            mAdapterStrings);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
    actionBar.setSelectedNavigationItem(0);

    onCreateNavigationListener();
    configureListNavigation();

    mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher);
    updateViewVisibility();

    onCreateHandleIntents();

    account.setDisplayedLaneDefinitionsDirty(false);

    configureNotificationService();
}

From source file:me.albertonicoletti.latex.activities.EditorActivity.java

/**
 * Routine to update the dataset/*from w w  w  . j a  va 2  s .  com*/
 */
private void refreshTitleAndDrawer() {
    String title = document.getName();
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setTitle(title);
    }
    documentsAdapter.refresh(documentsToFiles());
}

From source file:com.shafiq.mytwittle.view.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    // StrictMode.setThreadPolicy(new
    // StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDialog().build());
    // StrictMode.setThreadPolicy(new
    // StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
    // StrictMode.setVmPolicy(new
    // StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());

    super.onCreate(savedInstanceState);

    AccountDescriptor account = getApp().getCurrentAccount();

    // Attempt at fixing a crash found in HomeActivity
    if (account == null) {
        Toast.makeText(getApplicationContext(), "No cached account found, restarting",
                Constant.DEFAULT_TOAST_DISPLAY_TIME).show();
        restartApp();//  ww  w. j  a v  a  2s  .co m
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setTitle(null);
    actionBar.setDisplayShowTitleEnabled(false);

    ArrayList<String> adapterList = new ArrayList<String>();
    ArrayList<AccountDescriptor> accounts = getApp().getAccounts();
    for (int i = 0; i < accounts.size(); i++) {
        AccountDescriptor acc = accounts.get(i);
        adapterList.add("@" + acc.getScreenName()
                + (acc.getSocialNetType() == SocialNetConstant.Type.Appdotnet ? " (App.net)" : " (Twitter)"));
    }
    adapterList.add(getString(R.string.add_account));
    mAdapterStrings = adapterList.toArray(new String[adapterList.size()]);

    mSpinnerAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item,
            mAdapterStrings);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
    actionBar.setSelectedNavigationItem(0);

    onCreateNavigationListener();
    configureListNavigation();

    mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher);
    updateViewVisibility();

    onCreateHandleIntents();

    account.setDisplayedLaneDefinitionsDirty(false);

    configureNotificationService();
}

From source file:org.floens.chan.ui.activity.ChanActivity.java

private void updateActionBarStateCallback() {
    final ActionBar actionBar = getActionBar();

    if (threadPane.isSlideable()) {
        if (threadPane.isOpen()) {
            actionBar.setDisplayShowCustomEnabled(true);
            spinnerAdapter.setBoard(boardLoadable.board);
            actionBar.setTitle("");
            pinDrawerListener.setDrawerIndicatorEnabled(true);

            if (boardLoadable.isBoardMode()) {
                setShareUrl(ChanUrls.getBoardUrlDesktop(boardLoadable.board));
            } else if (boardLoadable.isCatalogMode()) {
                setShareUrl(ChanUrls.getCatalogUrlDesktop(boardLoadable.board));
            }//from w  w w . jav a2s  .c om
        } else {
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.setTitle(threadLoadable.title);
            pinDrawerListener.setDrawerIndicatorEnabled(false);

            if (threadLoadable.isThreadMode())
                setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    } else {
        actionBar.setDisplayShowCustomEnabled(true);
        pinDrawerListener.setDrawerIndicatorEnabled(true);
        actionBar.setTitle(threadLoadable.title);

        if (threadLoadable.isThreadMode()) {
            setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    }

    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);

    invalidateOptionsMenu();
}

From source file:com.concentricsky.android.khanacademy.app.VideoListActivity.java

@Override
protected void onStart() {
    Log.d(LOG_TAG, "onStart");
    super.onStart();
    stopped = false;//ww  w  . j a  va2  s  . c  om

    mainMenuDelegate = new MainMenuDelegate(this);

    listView = (AbsListView) findViewById(android.R.id.list);
    listView.setOnItemClickListener(clickListener);

    if (listView instanceof ListView) {
        // It is important that this is inflated with listView passed as the parent, despite the attach false parameter.
        // Otherwise, the view ends up with incorrect LayoutParams and we see crazy, crazy behavior.
        headerView = getLayoutInflater().inflate(R.layout.header_video_list, listView, false);
        ListView lv = (ListView) listView;
        if (lv.getHeaderViewsCount() == 0) {
            lv.addHeaderView(headerView);
        }
    } else { // GridView, fixed header
        headerView = findViewById(R.id.header_video_list);
    }

    /**  Responsive layout stuff 
     * 
     *  Based on screen width, we will find either
     *   narrow
     *     a listview with a header view
     *     items are a thumbnail to the left and a title on white space to the right.
     *     header is a thumbnail with overlaid title across the bottom
     * 
     *   middle
     *     a fixed header on top and a grid view below
     *     header is thumb to left, title above scrolling description to right
     *     items are thumbs with title overlaid across the bottom (3 across)
     *   
     *   wide
     *     a fixed header to the left and a grid view on the right
     *     header is thumb on top, title next, description at bottom
     *     items are thumbs with title overlaid across the bottom (3 across)
     *  
     *  
     *  So in this class, we 
     *    find view by id 'list'
     *    if it's a ListView, inflate and attach header view
     *    if not, then the header is fixed and already in the layout
     *    either way, now we can find header views by id
     *    adapter is the same either way
     *  
     *  
     *  
     *  **/

    ActionBar ab = getActionBar();
    displayOptionsAdapter = new ArrayAdapter<String>(getActionBar().getThemedContext(),
            android.R.layout.simple_list_item_1, displayOptions);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle("");
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    ab.setListNavigationCallbacks(displayOptionsAdapter, navListener);
    ab.setSelectedNavigationItem(isShowingDownloadedVideosOnly ? 1 : 0);

    requestDataService(new ObjectCallback<KADataService>() {
        @Override
        public void call(KADataService dataService) {
            VideoListActivity.this.dataService = dataService;

            if (topicId != null) {
                Dao<Topic, String> topicDao;
                try {
                    topicDao = dataService.getHelper().getTopicDao();
                    topic = topicDao.queryForId(topicId);
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            } else {
                Log.e(LOG_TAG, "Topic id not set for video list");
                topic = dataService.getRootTopic();
                topicId = topic.getId();
            }

            thumbnailManager = dataService.getThumbnailManager();
            api = dataService.getAPIAdapter();
            api.registerUserUpdateListener(userUpdateListener);

            // This instead happens in ActionBar.OnNavigationListener#onNavigationItemSelected, which
            // fires after onResume.
            //            setParentTopic(topic);
        }
    });

    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_LIBRARY_UPDATE);
    filter.addAction(ACTION_BADGE_EARNED);
    filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED);
    filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE);
    filter.addAction(ACTION_TOAST);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter);
    thumbExecutor = Executors.newSingleThreadExecutor();
}

From source file:com.example.android.cardreader.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.alternate_main_fragment);

    //TODO Stop Executing Eden
    //Globals.executeEden();
    getUsers(1);//  ww  w.  ja  v a  2  s . c om

    instance = this;
    final ActionBar actionBar = getActionBar();
    actionBar.setTitle("           TartanHacks");
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
    actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg));
    actionBar.setDisplayShowHomeEnabled(true);

    frags.add(new PersonListFrag(Globals.pending));
    frags.add(new PersonListFrag(Globals.allUsers));
    frags.add(new PersonListFrag(Globals.checkedIn));

    mAdapter = new FragmentAdapter(getFragmentManager());

    fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            View dialogView = View.inflate(instance, R.layout.dialog_signup, null);

            idField = (EditText) dialogView.findViewById(R.id.andrewIdField);
            pb = (ProgressBar) dialogView.findViewById(R.id.progress);
            nameField = (TextView) dialogView.findViewById(R.id.name);
            scanView = (TextView) dialogView.findViewById(R.id.scan_view);

            idField.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    String id = s.toString();
                    pb.setVisibility(View.VISIBLE);
                    queryId(id);

                }

                @Override
                public void afterTextChanged(Editable s) {

                }
            });

            AlertDialog.Builder builder;
            builder = new AlertDialog.Builder(instance);
            builder.setView(dialogView);
            builder.setCancelable(true);
            builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    Globals.adding = false;
                }
            });

            signupDialog = builder.show();
        }
    });

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(0);
    mViewPager.setAdapter(mAdapter);
    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);
        }
    });

    actionBar.addTab(actionBar.newTab().setText("Pending").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Checked In").setTabListener(this));

    mLoyaltyCardReader = new LoyaltyCardReader(this);

    // Disable Android Beam and register our card reader callback
    enableReaderMode();

    new UpdateThread().executeOnExecutor(Executors.newSingleThreadExecutor());
}

From source file:me.albertonicoletti.latex.activities.EditorActivity.java

/**
 * Initializes the navigation drawer./* ww  w .ja v a2s . c  o  m*/
 */
private void initDrawer() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    /* Recycler View containing the open documents */
    RecyclerView mDrawerList = (RecyclerView) findViewById(R.id.left_drawer);
    mDrawerList.setHasFixedSize(true);
    // Sets the layout manager
    /* Recycler View layout manager */
    RecyclerView.LayoutManager documentsLayoutManager = new LinearLayoutManager(this);
    mDrawerList.setLayoutManager(documentsLayoutManager);
    documentsAdapter = new DocumentsAdapter(documentsToFiles(), new DocumentClickListener(this),
            DocumentsAdapter.DRAWER);
    mDrawerList.setAdapter(documentsAdapter);
    mDrawerLayout.openDrawer(GravityCompat.START);
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.string.drawer_open, /* "open drawer" description */
            R.string.drawer_close /* "close drawer" description */
    ) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            ActionBar actionBar = getActionBar();
            if (actionBar != null) {
                actionBar.setTitle(document.getName());
            }
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            ActionBar actionBar = getActionBar();
            if (actionBar != null) {
                actionBar.setTitle("Choose File");
            }
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
}