List of usage examples for android.app Activity getActionBar
@Nullable
public ActionBar getActionBar()
From source file:run.ace.TabBar.java
public void show(android.app.Activity activity) { //if (!(activity instanceof ActionBarActivity)) { android.app.ActionBar mainActionBar = activity.getActionBar(); if (mainActionBar != null) { mainActionBar.show();//from w w w . j a va2s .co m mainActionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS); if (_primaryCommands != null) { for (int i = 0; i < _primaryCommands.size(); i++) { android.app.ActionBar.Tab tab = mainActionBar.newTab(); AppBarButton abb = (AppBarButton) _primaryCommands.get(i); if (abb.icon != null) { tab.setCustomView(getCustomTabView(abb, mainActionBar.getThemedContext())); } else { tab.setText(abb.label); } tab.setTabListener(this); mainActionBar.addTab(tab, i == 0); } } return; } throw new RuntimeException( "Cannot use TabBar on the main page in Android unless you set <preference name=\"ShowTitle\" value=\"true\"/> in config.xml."); //} //else { // ActionBar actionBar = ((ActionBarActivity)activity).getSupportActionBar(); // if (actionBar != null) { // actionBar.show(); // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // for (int i = 0; i < _primaryCommands.size(); i++) { // ActionBar.Tab tab = actionBar.newTab(); // AppBarButton abb = (AppBarButton)_primaryCommands.get(i); // if (abb.icon != null) { // tab.setCustomView(getCustomTabView(abb, actionBar.getThemedContext())); // } // else { // tab.setText(abb.label); // } // tab.setTabListener(this); // actionBar.addTab(tab); // } // return; // } // throw new RuntimeException( // "Unable to get TabBar from the current activity."); //} }
From source file:com.android.talkback.tutorial.TutorialLessonFragment.java
@Override public void onResume() { super.onResume(); Activity activity = getActivity(); if (activity != null) { ActionBar actionBar = activity.getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setCustomView(R.layout.tutorial_action_bar); actionBar.getCustomView().findViewById(R.id.up).setOnClickListener(this); TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title); title.setText(getTitle());/*from w w w . j av a 2 s .c om*/ LocalBroadcastManager.getInstance(activity).registerReceiver(mActionMonitor, GestureActionMonitor.FILTER); } TalkBackService service = TalkBackService.getInstance(); if (service != null) { service.addEventListener(mExercise); } }
From source file:org.dmfs.webcal.fragments.PagerFragment.java
@Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor);/*w w w .j a v a 2 s .c om*/ if (cursor == null) { // this indicates an error when loading the page, show an error message mMessageText.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.GONE); mViewPager.setVisibility(View.GONE); } else if (cursor.getCount() > 0) { // indicates the page has been loaded, hide progress indicator and show pager mMessageText.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE); mViewPager.setVisibility(View.VISIBLE); setupActionBarTabs(); } else { // all pages must have at least one section, 0 results means we're still waiting for the page to load, show a progress indicator Activity activity = getActivity(); mProgressBar.setVisibility(View.VISIBLE); activity.getActionBar().removeAllTabs(); activity.getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } }
From source file:org.dmfs.webcal.fragments.PagerFragment.java
@Override public void onPageSelected(int position) { Activity activity = getActivity(); if (activity == null) { // nothing to do return;/* w w w .ja v a 2 s .c o m*/ } ActionBar actionBar = activity.getActionBar(); if (actionBar != null && position != actionBar.getSelectedNavigationIndex()) { mSelectedTab = position; actionBar.setSelectedNavigationItem(position); } }
From source file:com.actionbarsherlock.internal.app.ActionBarWrapper.java
public ActionBarWrapper(Activity activity) { mActivity = activity;//from ww w .j a v a2s .c o m mActionBar = activity.getActionBar(); if (mActionBar != null) { mActionBar.addOnMenuVisibilityListener(this); } }
From source file:android.support.v7.app.ActionBarImplICS.java
public ActionBarImplICS(Activity activity, Callback callback) { mActivity = activity; mCallback = callback; mActionBar = activity.getActionBar(); }
From source file:net.sf.sprockets.app.NavigationDrawerToggle.java
/** * Manage the Activity's ActionBar and listen for navigation drawer events on the DrawerLayout. *///from ww w . j a v a 2s . c o m public NavigationDrawerToggle(Activity activity, DrawerLayout layout) { super(activity, layout, R.drawable.ic_drawer, R.string.open_navigation_drawer, R.string.close_navigation_drawer); mActivity = activity; mLayout = layout; mApp = activity.getPackageManager().getApplicationLabel(activity.getApplicationInfo()); mActionBar = activity.getActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); layout.setDrawerShadow(R.drawable.drawer_shadow, START); layout.setDrawerListener(this); }
From source file:android.support.v7.app.ActionBarImplCompatICS.java
public ActionBarImplCompatICS(Activity activity, Callback callback) { mActivity = activity; mCallback = callback; mActionBar = activity.getActionBar(); }
From source file:ca.rmen.android.palidamuerte.app.poem.list.PoemListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); new AsyncTask<Void, Void, String>() { @Override/*from w ww . ja va 2 s .c o m*/ protected String doInBackground(Void... params) { return Poems.getActivityTitle(activity, activity.getIntent()); } @Override protected void onPostExecute(String categoryName) { activity.getActionBar().setTitle(categoryName); } }.execute(); }
From source file:com.actionbarsherlock.sample.hcgallery.ContentFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.content_welcome, null); final ImageView imageView = (ImageView) mContentView.findViewById(R.id.image); mContentView.setDrawingCacheEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mContentView.setOnDragListener(new View.OnDragListener() { public boolean onDrag(View v, DragEvent event) { switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: mContentView.setBackgroundColor(getResources().getColor(R.color.drag_active_color)); break; case DragEvent.ACTION_DRAG_EXITED: mContentView.setBackgroundColor(Color.TRANSPARENT); break; case DragEvent.ACTION_DRAG_STARTED: return processDragStarted(event); case DragEvent.ACTION_DROP: mContentView.setBackgroundColor(Color.TRANSPARENT); return processDrop(event, imageView); }//ww w . j a v a 2s . co m return false; } }); // Keep the action bar visibility in sync with the system status bar. That is, when entering // 'lights out mode,' hide the action bar, and when exiting this mode, show the action bar. final Activity activity = getActivity(); mContentView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { public void onSystemUiVisibilityChange(int visibility) { ActionBar actionBar = activity.getActionBar(); if (actionBar != null) { mContentView.setSystemUiVisibility(visibility); if (visibility == View.STATUS_BAR_VISIBLE) { actionBar.show(); } else { actionBar.hide(); } } } }); // Show/hide the system status bar when single-clicking a photo. This is also called // 'lights out mode.' Activating and deactivating this mode also invokes the listener // defined above, which will show or hide the action bar accordingly. mContentView.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mContentView.getSystemUiVisibility() == View.STATUS_BAR_VISIBLE) { mContentView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); } else { mContentView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); } } }); } // When long-pressing a photo, activate the action mode for selection, showing the // contextual action bar (CAB). mContentView.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { if (mCurrentActionMode != null) { return false; } mCurrentActionMode = getActivity().startActionMode(mContentSelectionActionModeCallback); mContentView.setSelected(true); return true; } }); return mContentView; }