Java Code Examples for com.actionbarsherlock.app.ActionBar

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ActionBarSherlock, under directory /samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/.

Source file: Issue240.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.issue240);
  mPager=(ViewPager)findViewById(R.id.pager);
  mPager.setAdapter(new MyAdapter(getSupportFragmentManager()));
  mPager.setOnPageChangeListener(this);
  ActionBar ab=getSupportActionBar();
  ab.setNavigationMode(NAVIGATION_MODE_TABS);
  for (int i=1; i <= COUNT; i++) {
    ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this));
  }
}
 

Example 2

From project ActionBarSherlock, under directory /samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/.

Source file: Issue379.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ActionBar ab=getSupportActionBar();
  ab.setNavigationMode(NAVIGATION_MODE_TABS);
  ab.addTab(ab.newTab().setTabListener(this).setText("Test"));
  TextView tv=new TextView(this);
  tv.setText("ColorDrawable ignores bounds on pre-HC. Make sure you see three colors.");
  setContentView(tv);
}
 

Example 3

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: BranchViewer.java

  22 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  fixImageTilingOn(getSupportActionBar());
  setContentView(R.layout.branch_view);
  ActionBar actionBar=getSupportActionBar();
  setPrefixedTitleOn(actionBar,niceNameFor(repo()),shortenRefName(branch().getName()));
  actionBar.setDisplayHomeAsUpEnabled(true);
  pager.setAdapter(new BranchPagerAdapter(getSupportFragmentManager(),getResources(),gitdir(),branch()));
  tabPageIndicator.setViewPager(pager);
}
 

Example 4

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: MarkdownActivityBase.java

  22 
vote

/** 
 * Called when the activity is first created.
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  fixImageTilingOn(getSupportActionBar());
  setContentView(about_activity);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  configureActionBar(actionBar);
  MarkdownProcessor m=new MarkdownProcessor();
  String html=m.markdown(loadMarkdown());
  webView.loadDataWithBaseURL(null,html,"text/html","UTF-8",null);
}
 

Example 5

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.

Source file: AmenDetailFragmentActivity.java

  22 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Log.d(TAG,"--> onCreate");
  setContentView(R.layout.activity_fragment_amen_detail);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("Amendetails");
  FragmentManager fragmentManager=getSupportFragmentManager();
  amenDetailFragment=(AmenDetailFragment)fragmentManager.findFragmentById(R.id.activity_fragment_amen_detail);
}
 

Example 6

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.

Source file: ExploreFragmentActivity.java

  22 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_fragment_explore);
  FragmentManager fragmentManager=getSupportFragmentManager();
  exploreFragment=(ExploreFragment)fragmentManager.findFragmentById(R.id.activity_fragment_explore);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("Explore");
}
 

Example 7

From project Android, under directory /AndroidNolesCore/src/activities/.

Source file: AbstractMainActivity.java

  22 
vote

protected void addViewPagerWithTab(FragmentPagerAdapter adapter){
  mViewPager.setAdapter(adapter);
  mViewPager.setOnPageChangeListener(this);
  final ActionBar bar=getSupportActionBar();
  bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  bar.addTab(bar.newTab().setText("News").setTabListener(this));
  bar.addTab(bar.newTab().setText("Team").setTabListener(this));
  bar.addTab(bar.newTab().setText("Link").setTabListener(this));
}
 

Example 8

From project Android, under directory /app/src/main/java/com/github/mobile/ui/commit/.

Source file: CommitCompareViewActivity.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(layout.commit_compare);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setSubtitle(repository.generateId());
  avatars.bind(actionBar,repository.getOwner());
  fragment=(SherlockFragment)getSupportFragmentManager().findFragmentById(android.R.id.list);
}
 

Example 9

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: SettingsActivity.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  ActionBar bar=getSupportActionBar();
  bar.setHomeButtonEnabled(true);
  bar.setDisplayHomeAsUpEnabled(true);
}
 

Example 10

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: AbstractWalletActivity.java

  22 
vote

@Override protected void onStart(){
  super.onStart();
  final ActionBar actionBar=getSupportActionBar();
  actionBar.setIcon(R.drawable.app_icon);
  actionBar.setSubtitle(Constants.TEST ? "[testnet3]" : null);
}
 

Example 11

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: PeerMonitorActivity.java

  22 
vote

@Override protected void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.peer_monitor_content);
  final ActionBar actionBar=getSupportActionBar();
  actionBar.setTitle(R.string.peer_monitor_activity_title);
  actionBar.setDisplayHomeAsUpEnabled(true);
}
 

Example 12

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: MainActivity.java

  21 
vote

@Override public boolean onKeyDown(final int keyCode,final KeyEvent event){
  final ActionBar actionBar=getSupportActionBar();
  if (actionBar.getSelectedNavigationIndex() == TWITTER_FRAGMENT_INDEX) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
        final WebFragment webFragment=(WebFragment)mTabsAdapter.getItem(TWITTER_FRAGMENT_INDEX);
      if (webFragment.goBack()) {
        return true;
      }
  }
}
}
return super.onKeyDown(keyCode,event);
}
 

Example 13

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: TiledMapActivity.java

  21 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.tilemap);
  ActionBar bar=getSupportActionBar();
  bar.setHomeButtonEnabled(true);
  bar.setDisplayHomeAsUpEnabled(true);
  view=(TiledMapView)findViewById(R.id.tiledmap);
  view.setOnShortPressListener(shortPressListener);
  view.setOnLongPressListener(longPressListener);
  Intent i=getIntent();
  if (i.hasExtra(C.EXTRA_MAP_ID)) {
    mapId=i.getLongExtra(C.EXTRA_MAP_ID,-1);
    view.restoreFromJSON(i.getStringExtra(C.EXTRA_MAP_JSON));
    getSupportActionBar().setTitle(view.getMapName());
  }
 else {
    int rows=i.getIntExtra(C.EXTRA_MAP_ROWS,-1);
    int columns=i.getIntExtra(C.EXTRA_MAP_COLUMNS,-1);
    if (rows != -1 && columns != -1) {
      view.initMap(rows,columns);
    }
 else {
      Log.e(TAG,MessageFormat.format("missing dimensions (rows={0}, columns={1}",rows,columns));
    }
    showDialog(C.DIALOG_RENAME_MAP);
  }
  adapter=new ImageAdapter(TiledMapActivity.this);
  try {
    String[] tileSets=getAssets().list("gfx");
    for (    String tileSet : tileSets) {
      adapter.addFromAssets("gfx/" + tileSet);
    }
  }
 catch (  IOException ioex) {
    ioex.printStackTrace();
  }
  registerForContextMenu(view);
}
 

Example 14

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/ui/.

Source file: TwunchListActivity.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_twunch_list);
  mViewPager=(ViewPager)findViewById(R.id.home_pager);
  mMyAdapter=new MyAdapter(getSupportFragmentManager());
  mViewPager.setAdapter(mMyAdapter);
  mViewPager.setOffscreenPageLimit(2);
  mViewPager.setOnPageChangeListener(this);
  getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  final ActionBar bar=getSupportActionBar();
  bar.addTab(bar.newTab().setText(R.string.tab_date).setTabListener(this),false);
  bar.addTab(bar.newTab().setText(R.string.tab_distance).setTabListener(this),false);
  bar.addTab(bar.newTab().setText(R.string.menu_map).setTabListener(this),false);
  bar.setSelectedNavigationItem(PrefsUtils.getLastTab());
  resultReceiver=new DetachableResultReceiver(new Handler());
  resultReceiver.setReceiver(new SyncResultReceiver());
  locationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
  locationListener=new LocationListener(){
    public void onLocationChanged(    Location location){
      if (location != null) {
        new UpdateDistancesTask().execute(location);
      }
    }
    public void onStatusChanged(    String provider,    int status,    Bundle extras){
    }
    public void onProviderEnabled(    String provider){
    }
    public void onProviderDisabled(    String provider){
    }
  }
;
}
 

Example 15

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  19 
vote

private void configureTab(Tab tab,int position){
  final TabImpl tabi=(TabImpl)tab;
  final ActionBar.TabListener callback=tabi.getCallback();
  if (callback == null) {
    throw new IllegalStateException("Action Bar Tab must have a Callback");
  }
  tabi.setPosition(position);
  mTabs.add(position,tabi);
  final int count=mTabs.size();
  for (int i=position + 1; i < count; i++) {
    mTabs.get(i).setPosition(i);
  }
}
 

Example 16

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  19 
vote

@Override public void setCustomView(View view,LayoutParams layoutParams){
  android.app.ActionBar.LayoutParams lp=new android.app.ActionBar.LayoutParams(layoutParams);
  lp.gravity=layoutParams.gravity;
  lp.bottomMargin=layoutParams.bottomMargin;
  lp.topMargin=layoutParams.topMargin;
  lp.leftMargin=layoutParams.leftMargin;
  lp.rightMargin=layoutParams.rightMargin;
  mActionBar.setCustomView(view,lp);
}
 

Example 17

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  19 
vote

private void configureTab(Tab tab,int position){
  final TabImpl tabi=(TabImpl)tab;
  final ActionBar.TabListener callback=tabi.getCallback();
  if (callback == null) {
    throw new IllegalStateException("Action Bar Tab must have a Callback");
  }
  tabi.setPosition(position);
  mTabs.add(position,tabi);
  final int count=mTabs.size();
  for (int i=position + 1; i < count; i++) {
    mTabs.get(i).setPosition(i);
  }
}
 

Example 18

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  19 
vote

@Override public void setCustomView(View view,LayoutParams layoutParams){
  android.app.ActionBar.LayoutParams lp=new android.app.ActionBar.LayoutParams(layoutParams);
  lp.gravity=layoutParams.gravity;
  lp.bottomMargin=layoutParams.bottomMargin;
  lp.topMargin=layoutParams.topMargin;
  lp.leftMargin=layoutParams.leftMargin;
  lp.rightMargin=layoutParams.rightMargin;
  mActionBar.setCustomView(view,lp);
}
 

Example 19

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: MainActivity.java

  19 
vote

@Override protected void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  final ActionBar.Tab tab1=getSupportActionBar().newTab().setText(R.string.podcast);
  final ActionBar.Tab tab2=getSupportActionBar().newTab().setText(R.string.twitter);
  mViewPager=(ViewPager)findViewById(R.id.pager);
  mTabsAdapter=new TabsAdapter(this,getSupportActionBar(),mViewPager);
  mTabsAdapter.addTab(tab1,RssListFragment.class);
  mTabsAdapter.addTab(tab2,WebFragment.class);
  if (savedInstanceState != null) {
    getSupportActionBar().setSelectedNavigationItem(savedInstanceState.getInt("index"));
  }
}
 

Example 20

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  19 
vote

private void configureTab(Tab tab,int position){
  final TabImpl tabi=(TabImpl)tab;
  final ActionBar.TabListener callback=tabi.getCallback();
  if (callback == null) {
    throw new IllegalStateException("Action Bar Tab must have a Callback");
  }
  tabi.setPosition(position);
  mTabs.add(position,tabi);
  final int count=mTabs.size();
  for (int i=position + 1; i < count; i++) {
    mTabs.get(i).setPosition(i);
  }
}
 

Example 21

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  19 
vote

@Override public void setCustomView(View view,LayoutParams layoutParams){
  android.app.ActionBar.LayoutParams lp=new android.app.ActionBar.LayoutParams(layoutParams);
  lp.gravity=layoutParams.gravity;
  lp.bottomMargin=layoutParams.bottomMargin;
  lp.topMargin=layoutParams.topMargin;
  lp.leftMargin=layoutParams.leftMargin;
  lp.rightMargin=layoutParams.rightMargin;
  mActionBar.setCustomView(view,lp);
}
 

Example 22

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  19 
vote

private void configureTab(Tab tab,int position){
  final TabImpl tabi=(TabImpl)tab;
  final ActionBar.TabListener callback=tabi.getCallback();
  if (callback == null) {
    throw new IllegalStateException("Action Bar Tab must have a Callback");
  }
  tabi.setPosition(position);
  mTabs.add(position,tabi);
  final int count=mTabs.size();
  for (int i=position + 1; i < count; i++) {
    mTabs.get(i).setPosition(i);
  }
}
 

Example 23

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  19 
vote

@Override public void setCustomView(View view,LayoutParams layoutParams){
  android.app.ActionBar.LayoutParams lp=new android.app.ActionBar.LayoutParams(layoutParams);
  lp.gravity=layoutParams.gravity;
  lp.bottomMargin=layoutParams.bottomMargin;
  lp.topMargin=layoutParams.topMargin;
  lp.leftMargin=layoutParams.leftMargin;
  lp.rightMargin=layoutParams.rightMargin;
  mActionBar.setCustomView(view,lp);
}
 

Example 24

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  19 
vote

private void configureTab(Tab tab,int position){
  final TabImpl tabi=(TabImpl)tab;
  final ActionBar.TabListener callback=tabi.getCallback();
  if (callback == null) {
    throw new IllegalStateException("Action Bar Tab must have a Callback");
  }
  tabi.setPosition(position);
  mTabs.add(position,tabi);
  final int count=mTabs.size();
  for (int i=position + 1; i < count; i++) {
    mTabs.get(i).setPosition(i);
  }
}
 

Example 25

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  19 
vote

@Override public void setCustomView(View view,LayoutParams layoutParams){
  android.app.ActionBar.LayoutParams lp=new android.app.ActionBar.LayoutParams(layoutParams);
  lp.gravity=layoutParams.gravity;
  lp.bottomMargin=layoutParams.bottomMargin;
  lp.topMargin=layoutParams.topMargin;
  lp.leftMargin=layoutParams.leftMargin;
  lp.rightMargin=layoutParams.rightMargin;
  mActionBar.setCustomView(view,lp);
}
 

Example 26

From project callmeter, under directory /src/de/ub0r/android/callmeter/.

Source file: CallMeter.java

  19 
vote

/** 
 * Fix ActionBar background. See http://b.android.com/15340.
 * @param ab {@link ActionBar}
 * @param r {@link Resources}
 * @param bg res id of background  {@link BitmapDrawable}
 * @param bgSplit res id of background  {@link BitmapDrawable} in split mode
 */
public static void fixActionBarBackground(final ActionBar ab,final Resources r,final int bg,final int bgSplit){
  BitmapDrawable d=(BitmapDrawable)r.getDrawable(bg);
  d.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT);
  ab.setBackgroundDrawable(d);
  if (bgSplit >= 0) {
    d=(BitmapDrawable)r.getDrawable(bgSplit);
    d.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT);
    ab.setSplitBackgroundDrawable(d);
  }
}
 

Example 27

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarImpl.java

  19 
vote

private void configureTab(Tab tab,int position){
  final TabImpl tabi=(TabImpl)tab;
  final ActionBar.TabListener callback=tabi.getCallback();
  if (callback == null) {
    throw new IllegalStateException("Action Bar Tab must have a Callback");
  }
  tabi.setPosition(position);
  mTabs.add(position,tabi);
  final int count=mTabs.size();
  for (int i=position + 1; i < count; i++) {
    mTabs.get(i).setPosition(i);
  }
}
 

Example 28

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarWrapper.java

  19 
vote

@Override public void setCustomView(View view,LayoutParams layoutParams){
  android.app.ActionBar.LayoutParams lp=new android.app.ActionBar.LayoutParams(layoutParams);
  lp.gravity=layoutParams.gravity;
  lp.bottomMargin=layoutParams.bottomMargin;
  lp.topMargin=layoutParams.topMargin;
  lp.leftMargin=layoutParams.leftMargin;
  lp.rightMargin=layoutParams.rightMargin;
  mActionBar.setCustomView(view,lp);
}