List of usage examples for android.app ActionBar setListNavigationCallbacks
@Deprecated public abstract void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback);
From source file:com.bignerdranch.android.fragmentbasics.NewsReaderActivity.java
/** Sets up Action Bar (if present). * * @param showTabs whether to show tabs (if false, will show list). * @param selTab the selected tab or list item. *//*from w w w . j ava 2 s . co m*/ public void setUpActionBar(boolean showTabs, int selTab) { if (Build.VERSION.SDK_INT < 11) { // No action bar for you! // But do not despair. In this case the layout includes a bar across the // top that looks and feels like an action bar, but is made up of regular views. return; } android.app.ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); // Set up a CompatActionBarNavHandler to deliver us the Action Bar nagivation events CompatActionBarNavHandler handler = new CompatActionBarNavHandler(this); if (showTabs) { actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS); int i; for (i = 0; i < CATEGORIES.length; i++) { actionBar.addTab(actionBar.newTab().setText(CATEGORIES[i]).setTabListener(handler)); } actionBar.setSelectedNavigationItem(selTab); } else { actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); SpinnerAdapter adap = new ArrayAdapter<String>(this, R.layout.actionbar_list_item, CATEGORIES); actionBar.setListNavigationCallbacks(adap, handler); } // Show logo instead of icon+title. actionBar.setDisplayUseLogoEnabled(true); }
From source file:com.concentricsky.android.khanacademy.app.VideoListActivity.java
@Override protected void onStart() { Log.d(LOG_TAG, "onStart"); super.onStart(); stopped = false;/*from ww w. j av a 2s . c o m*/ 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.schedule.ScheduleActivity.java
/** * Sets up Action Bar (if present).//from ww w. java 2s .c o m * * @param showTabs * whether to show tabs (if false, will show list). * @param selTab * the selected tab or list item. */ public void setUpActionBar(boolean showTabs, int selTab) { if (Build.VERSION.SDK_INT < 11) { // No action bar for you! // But do not despair. In this case the layout includes a bar across // the // top that looks and feels like an action bar, but is made up of // regular views. return; } android.app.ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); // Set up a CompatActionBarNavHandler to deliver us the Action Bar // nagivation events CompatActionBarNavHandler handler = new CompatActionBarNavHandler(this); if (showTabs) { actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS); int i; for (i = 0; i < MENUS.length; i++) { actionBar.addTab(actionBar.newTab().setText(MENUS[i]).setTabListener(handler)); } actionBar.setSelectedNavigationItem(selTab); } else { actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); SpinnerAdapter adap = new ArrayAdapter<String>(this, R.layout.actionbar_list_item, MENUS); actionBar.setListNavigationCallbacks(adap, handler); } // Show logo instead of icon+title. actionBar.setDisplayUseLogoEnabled(true); }
From source file:cz.urbangaming.galgs.GAlg.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayList<String> itemList = new ArrayList<String>(); //TODO:Make static, use String constants strings.xml itemList.add(getResources().getString(R.string.workmode_add)); itemList.add(getResources().getString(R.string.workmode_edit)); itemList.add(getResources().getString(R.string.workmode_delete)); this.aAdpt = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, itemList);/*from w w w. ja va 2 s .c o m*/ actionBar.setListNavigationCallbacks(aAdpt, this); mGLSurfaceView = new GLSurfaceView(this); if (detectOpenGLES20()) { // Tell the surface view we want to create an OpenGL ES 2.0-compatible // context, and set an OpenGL ES 2.0-compatible renderer. mGLSurfaceView.setEGLContextClientVersion(2); pointsRenderer = new PointsRenderer(this); mGLSurfaceView.setRenderer(pointsRenderer); } else { // TODO: Handle as an unrecoverable error and leave the activity somehow... } // External files preparation InputStream in = null; OutputStream out = null; try { Log.d(DEBUG_TAG, "Media rady: " + isExternalStorageWritable()); AssetManager assetManager = getAssets(); in = assetManager.open(GALGS_CLASS_FILE); if (in != null) { galgsRubyClassesDirectory = new File(GALGS_CLASS_DIR); galgsRubyClassesDirectory.mkdir(); if (!galgsRubyClassesDirectory.isDirectory()) { Log.d(DEBUG_TAG, "Hmm, " + galgsRubyClassesDirectory + " does not exist, trying mkdirs..."); galgsRubyClassesDirectory.mkdirs(); } File outputFile = new File(galgsRubyClassesDirectory, GALGS_CLASS_FILE); if (outputFile.exists()) { // Load from what user might have edited outputFile = new File(galgsRubyClassesDirectory, GALGS_CLASS_FILE + ".orig"); } out = new FileOutputStream(outputFile); copyFile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } else { Log.e("IO HELL", "Asset " + GALGS_CLASS_FILE + " not found..."); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Stops the thing from trashing the context on pause/resume. mGLSurfaceView.setPreserveEGLContextOnPause(true); setContentView(mGLSurfaceView); }
From source file:com.tweetlanes.android.core.view.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { AccountDescriptor account = getApp().getCurrentAccount(); Bundle extras = getIntent().getExtras(); if (extras != null) { // Notifications String accountKey = extras.getString("account_key"); String notificationType = extras.getString("notification_type"); long notificationPostId = extras.getLong("notification_post_id"); String laneName = extras.getString("lane"); final String urlToLoad = extras.getString("urlToLoad"); if (accountKey != null) { getIntent().removeExtra("account_key"); getIntent().removeExtra("notification_type"); AccountDescriptor notificationAccount = getApp().getAccountByKey(accountKey); Notifier.saveLastNotificationActioned(this, accountKey, notificationType, notificationPostId); Constant.LaneType notificationLaneType = notificationType.equals( SharedPreferencesConstants.NOTIFICATION_TYPE_MENTION) ? Constant.LaneType.USER_MENTIONS : Constant.LaneType.DIRECT_MESSAGES; if (notificationAccount != null) { long notificationAccountId = notificationAccount.getId(); long currentAccountId = account.getId(); if (notificationAccountId == currentAccountId) { int index = account.getCurrentLaneIndex(notificationLaneType); if (index > -1) { mDefaultLaneOverride = index; }/*from w w w. j a v a 2s. c om*/ } else { showAccount(notificationAccount, notificationLaneType); } } } else if (laneName != null) { getIntent().removeExtra("lane"); int index = account.getCurrentLaneIndex(Constant.LaneType.valueOf(laneName.trim().toUpperCase())); if (index > -1) { mDefaultLaneOverride = index; } } else if (urlToLoad != null) { getIntent().removeExtra("urlToLoad"); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage(getString(R.string.unknown_intent)); alertDialogBuilder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse(urlToLoad.trim())); startActivity(viewIntent); } }); alertDialogBuilder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialogBuilder.create().show(); } } super.onCreate(savedInstanceState); // 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(); return; } ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setTitle(null); actionBar.setDisplayShowTitleEnabled(false); mSpinnerAdapter = new AccountAdapter(this, getApp().getAccounts()); 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); Notifier.setNotificationAlarm(this); clearTempFolder(); cacheFollowers(); //Launch change log dialog final WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this); whatsNewDialog.show(); }
From source file:com.geotrackin.gpslogger.GpsMainActivity.java
public void SetUpActionBar() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.gps_main_views, android.R.layout.simple_spinner_dropdown_item); actionBar.setListNavigationCallbacks(spinnerAdapter, this); //Reload the user's previously selected view f73 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); actionBar.setSelectedNavigationItem(prefs.getInt("dropdownview", 0)); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(""); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(R.layout.actionbar); ImageButton helpButton = (ImageButton) actionBar.getCustomView().findViewById(R.id.imgHelp); helpButton.setOnClickListener(new View.OnClickListener() { @Override// w ww. ja va2 s .com public void onClick(View view) { Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class); startActivity(faqtivity); } }); }
From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java
/** * Load the list of currently live sessions or upcoming live sessions. This * populates the Action Bar (either the title or as list navigation. *///w w w . j a v a2s .co m private void loadSessionsList(Cursor data) { mLivestreamAdapter.swapCursor(data); if (data != null && data.getCount() > 0) { mSessionsFound = true; final ActionBar actionBar = getActionBar(); if (data.getCount() == 1) { // Just one session on, display title in Action Bar if (data.moveToFirst()) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(data.getString(SessionsQuery.TITLE)); } } else if (data.getCount() > 1) { // 2+ sessions found, set Action Bar to list navigation (spinner) actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mLivestreamAdapter, this); actionBar.setDisplayShowTitleEnabled(false); getActionBar().setSelectedNavigationItem(locateSelectedItem(data)); } } else if (mSessionsFound) { // Sessions were previously found but no sessions are currently live, // adjust query to see if there are any future sessions at all mSessionsFound = false; final Bundle bundle = new Bundle(); bundle.putBoolean(LOADER_SESSIONS_ARG, true); getLoaderManager().restartLoader(SessionsQuery._TOKEN, bundle, this); } else { // No sessions live right now and no sessions coming up, get out finish(); } }
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 ww w.jav a 2s . 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: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();/* www . 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:com.nononsenseapps.notepad.MainActivity.java
private void leftOrTabletCreate(Bundle savedInstanceState) { if (savedInstanceState != null) { // currentListId = savedInstanceState.getLong(CURRENT_LIST_ID); listIdToSelect = savedInstanceState.getLong(CURRENT_LIST_ID); // currentListPos = savedInstanceState.getInt(CURRENT_LIST_POS); }// w ww.jav a 2 s. c o m // Set up dropdown navigation final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // Will set cursor in Loader // mSpinnerAdapter = new ExtrasCursorAdapter(this, // R.layout.actionbar_dropdown_item, null, // new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, // new int[] { android.R.id.text1 }, new int[] { -9, -8 }, // new int[] { R.string.show_from_all_lists, R.string.error_title }); mSpinnerAdapter = new SimpleCursorAdapter(this, R.layout.actionbar_dropdown_item, null, new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, new int[] { android.R.id.text1 }, 0); mSpinnerAdapter.setDropDownViewResource(R.layout.actionbar_dropdown_item); // This will listen for navigation callbacks actionBar.setListNavigationCallbacks(mSpinnerAdapter, this); // setContentView(R.layout.fragment_layout); // setUpList(); mSectionAdapter = new SimpleCursorAdapter(this, R.layout.actionbar_dropdown_item, null, new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, new int[] { android.R.id.text1 }, 0); mSectionsPagerAdapter = new ListPagerAdapter(this, getFragmentManager(), mSectionAdapter); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.leftFragment); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int pos) { currentListId = mSectionsPagerAdapter.getItemId(pos); currentListPos = pos; actionBar.setSelectedNavigationItem(pos); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); // Set up navigation list // Set a default list to open if one is set if (listIdToSelect < 0) { listIdToSelect = getAList(this, -1); // Select the first note in that list to open also noteIdToSelect = getANote(this, listIdToSelect); } // Handle the intent first, so we know what to possibly select once // the // loader is finished beforeBoot = true; if (!resuming) { onNewIntent(getIntent()); } getLoaderManager().initLoader(0, null, this); }