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

    frag = (EditorFragment) getFragmentManager().findFragmentById(android.R.id.content);

    if (frag == null) {
      frag = new EditorFragment();
      getFragmentManager().beginTransaction().add(android.R.id.content, frag).commit();
    }

    if (savedInstanceState != null) {
      models = savedInstanceState.getCharSequenceArray(KEY_MODELS);
    }

    ArrayAdapter<String> nav = null;
    ActionBar bar = getActionBar();
    nav = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, labels);
    nav.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    bar.setListNavigationCallbacks(nav, this);

    if (savedInstanceState != null) {
      bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_POSITION));
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    overridePendingTransition(R.anim.fadein, R.anim.fadeout);

    // ....................................
    // Load state of filter from Bundle
    if (savedInstanceState != null) {
      mSeriesFilter = savedInstanceState.getString("mSeriesFilter");
      mFilterMode = savedInstanceState.getInt("mFilterMode");
      if (mSeriesFilter == null) mSeriesFilter = ""; // if no filter found
    } else {
      // if no state, load in default pref.
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      String tmp = prefs.getString("libraryFilter", "0");
      this.mFilterMode = Integer.parseInt(tmp);
    } // if

    // ....................................
    mThumbPath =
        Environment.getExternalStorageDirectory().getAbsolutePath() + "/OpenComicReader/thumbs/";
    mSpinAdapter =
        new ArrayAdapter<String>(
            this,
            android.R.layout.simple_spinner_dropdown_item,
            this.getResources().getStringArray(R.array.libraryFilter));

    // ....................................
    // Setup Actionbar
    ActionBar mActionBar = this.getActionBar();
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    mActionBar.setDisplayShowTitleEnabled(false);
    mActionBar.setListNavigationCallbacks(mSpinAdapter, this);
    mActionBar.setSelectedNavigationItem(mFilterMode);
    mActionBar.setDisplayOptions(
        ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME);
    mActionBar.setCustomView(R.layout.activity_main_actionbar);
    mCountLbl = (TextView) mActionBar.getCustomView().findViewById(R.id.lblCount);
    mSeriesLbl = (TextView) mActionBar.getCustomView().findViewById(R.id.lblSeries);

    // ....................................
    // Setup Main View Area
    mAdapter = new SqlCursorAdapter(this);
    mAdapter.setItemLayout(R.layout.listitem_main);

    mGridView = (GridView) findViewById(R.id.lvMain);
    mGridView.setAdapter(mAdapter);
    mGridView.setOnItemClickListener(this);

    registerForContextMenu(mGridView); // Route event from Activity to View

    // ....................................
    // Start DB and Data Loader
    mDb = new Sqlite(this);
    mDb.openRead();

    getSupportLoaderManager().initLoader(0, null, this);
  } // func
  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {

    super.onRestoreInstanceState(savedInstanceState);

    ActionBar actionBar = getActionBar();

    if (actionBar != null && actionBar.getTabCount() > 1)
      actionBar.setSelectedNavigationItem(savedInstanceState.getInt(getString(R.string.key_tab)));
  }
  public boolean setSelectedAction(int type) {
    if (mActionBar == null) return false;

    for (int i = 0, n = sClusterItems.length; i < n; i++) {
      ActionItem item = sClusterItems[i];
      if (item.action == type) {
        mActionBar.setSelectedNavigationItem(i);
        mCurrentIndex = i;
        return true;
      }
    }
    return false;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
      case (R.id.action_settings):
        //	    Toast.makeText(this.getParent(), "Settaggi", Toast.LENGTH_LONG).show();
        new ToastMessageTask().execute("Settaggi");
        actionBar.setSelectedNavigationItem(5);
        //	    actionBar.setSelectedNavigationItem(5);

        break;
    }

    return super.onOptionsItemSelected(item);
  }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_pager);
    mViewPager = (ViewPager) findViewById(R.id.pager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_ftp), WebViewActivity.class, null);
    mTabsAdapter.addTab(
        bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null);
    if (savedInstanceState != null) {
      bar.setSelectedNavigationItem(savedInstanceState.getInt(INSTANCESTATE_TAB, 0));
    }
  }
Exemple #7
0
 /**
  * This is meant to be called from the intent handling. It handles the two possible cases that
  * this app was already running when it received the intent or it was started fresh with the
  * intent meaning we have to handle the opening asynchronously.
  *
  * @param listId
  */
 private void openListFromIntent(long listId) {
   if (beforeBoot) {
     // Set the variable to be selected after the loader has
     // finished its query
     listIdToSelect = listId;
     Log.d(TAG, "beforeBoot setting future id");
   } else {
     // Select the list directly since the loader is done
     int pos = getPosOfId(listId);
     Log.d("FragmentLayout", "pos: " + pos);
     if (pos > -1) {
       // select it
       ActionBar ab = getActionBar();
       if (ab != null && ab.getSelectedNavigationIndex() != pos) {
         ab.setSelectedNavigationItem(pos);
       }
     }
   }
 }
 public void enableAlbumModeMenu(int selected, OnAlbumModeSelectedListener listener) {
   if (mActionBar != null) {
     if (mAlbumModeAdapter == null) {
       // Initialize the album mode options if they haven't been already
       Resources res = mActivity.getResources();
       mAlbumModes =
           new CharSequence[] {
             res.getString(R.string.switch_photo_filmstrip),
             res.getString(R.string.switch_photo_grid)
           };
       mAlbumModeAdapter = new AlbumModeAdapter();
     }
     mAlbumModeListener = null;
     mLastAlbumModeSelected = selected;
     mActionBar.setListNavigationCallbacks(mAlbumModeAdapter, this);
     mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
     mActionBar.setSelectedNavigationItem(selected);
     mAlbumModeListener = listener;
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_profile);

    fragmentManager = getFragmentManager();

    ActionBar actionBar = getActionBar();

    // Hide ActionBar Icon
    actionBar.setDisplayShowHomeEnabled(false);

    // Hide ActionBar Title
    actionBar.setDisplayShowTitleEnabled(false);

    // Create ActionBar Tabs
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set Tab Icon and Titles
    Profile = actionBar.newTab().setText("Profile");
    Events = actionBar.newTab().setText("Events");

    // Set Tab Listeners
    Profile.setTabListener(new TabListener(fragmentProfileTab));
    Events.setTabListener(new TabListener(fragmentEventsTab));

    // Add Tabs to ActionBar
    actionBar.addTab(Profile);
    actionBar.addTab(Events);

    // Get which tab is selected from the intent
    Intent fromHomeView = getIntent();
    String tabSelected = fromHomeView.getStringExtra("tabSelected");
    int tabPosition = 0;
    if (tabSelected != null && tabSelected.equals("events")) {
      tabPosition = 1;
    }

    actionBar.setSelectedNavigationItem(tabPosition);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Intent service = new Intent(this, LocationService.class);
    // startService(service);
    this.viewPager = new ScrollableViewPager(this);
    this.viewPager.setId(R.id.viewPager);
    setContentView(viewPager);

    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    tabsAdapter = new TabsAdapter(this, viewPager);
    tabsAdapter.addTab(
        actionBar.newTab().setIcon(android.R.drawable.ic_menu_mapmode),
        FragmentMapView.class,
        null);
    tabsAdapter.addTab(
        actionBar.newTab().setIcon(android.R.drawable.ic_menu_sort_by_size),
        FragmentListView.class,
        null);
    tabsAdapter.addTab(
        actionBar.newTab().setIcon(android.R.drawable.ic_menu_gallery),
        FragmentImageGridView.class,
        null);

    if (savedInstanceState != null) {
      actionBar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
      if (savedInstanceState.getBoolean("isSearching")) {
        this.onSearchRequested();
      }
    }

    // TODO Removed for now until better implementation
    // this.startService(new Intent(this, LocationService.class));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Network State"), NetworkStateFragment.class, null);

    mTabsAdapter.addTab(bar.newTab().setText("Connection"), ConnectionWatcher.class, null);

    mTabsAdapter.addTab(bar.newTab().setText("Upload Trace"), TraceExchangeFragment.class, null);

    if (savedInstanceState != null) {
      bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
  }
 public Tab GetTabAtIndex(int _index) {
   ActionBar actionBar = this.controls.activity.getActionBar();
   actionBar.setSelectedNavigationItem(_index);
   return actionBar.getTabAt(_index);
 }
 public void SetTabNavigationMode() {
   ActionBar actionBar = this.controls.activity.getActionBar();
   actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // API 11
   actionBar.setSelectedNavigationItem(0);
 }
 public void setListNavSelectIndex(int position) {
   ActionBar actionBar = getActionBar();
   actionBar.setSelectedNavigationItem(position);
 }
 public void onPageSelected(int position) {
   mActionBar.setSelectedNavigationItem(position);
 }
 public void SelectTabByIndex(int _index) {
   ActionBar actionBar = this.controls.activity.getActionBar();
   actionBar.setSelectedNavigationItem(_index);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate()");
    //		FragmentManager.enableDebugLogging(true);

    super.onCreate(savedInstanceState);

    appName = getDbAdapter().getAppName(packageName);
    hasRevenue = getIntent().getBooleanExtra(EXTRA_HAS_REVENUE, true);

    ActionBar actionBar = getActionBar();

    if (iconFilePath != null) {
      if (getLastNonConfigurationInstance() != null) {
        loadBitmap = (LoadBitmap) getLastNonConfigurationInstance();
        loadBitmap.attach(this);
        if (loadBitmap.bitmap != null) {
          setActionBarIcon(loadBitmap.bitmap);
        }
      } else {
        loadBitmap = new LoadBitmap(this);
        Utils.execute(loadBitmap, iconFilePath);
      }
    }

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    Tab tab =
        actionBar
            .newTab()
            .setText(R.string.comments)
            .setTabListener(
                new TabListener<CommentsFragment>(this, "comments_tab", CommentsFragment.class));
    actionBar.addTab(tab);

    tab =
        actionBar
            .newTab()
            .setText(R.string.ratings)
            .setTabListener(
                new TabListener<RatingsFragment>(this, "ratings_tab", RatingsFragment.class));
    actionBar.addTab(tab);

    tab =
        actionBar
            .newTab()
            .setText(R.string.downloads)
            .setTabListener(
                new TabListener<DownloadsFragment>(this, "downloads_tab", DownloadsFragment.class));
    actionBar.addTab(tab);

    if (hasRevenue) {
      tab =
          actionBar
              .newTab()
              .setText(R.string.revenue)
              .setTabListener(
                  new TabListener<RevenueFragment>(this, "revenue_tab", RevenueFragment.class));
      actionBar.addTab(tab);
    }

    // Check if AdMob is configured for this app
    String[] admobDetails = AndlyticsDb.getInstance(this).getAdmobDetails(packageName);
    boolean admobConfigured = admobDetails != null;
    if (admobConfigured || !Preferences.getHideAdmobForUnconfiguredApps(this)) {
      tab =
          actionBar
              .newTab()
              .setText(R.string.admob)
              .setTabListener(
                  new TabListener<AdmobFragment>(this, "admob_tab", AdmobFragment.class));
      actionBar.addTab(tab);
    }

    int selectedTabIdx = getIntent().getExtras().getInt(EXTRA_SELECTED_TAB_IDX, 0);
    // FIXME This is a hack to select AdMob in the case that the revenue tab isn't enabled
    if (!hasRevenue && selectedTabIdx == TAB_IDX_ADMOB) {
      selectedTabIdx = TAB_IDX_REVENUE;
    }
    if (savedInstanceState != null) {
      selectedTabIdx = savedInstanceState.getInt(EXTRA_SELECTED_TAB_IDX, 0);
    }
    if (selectedTabIdx < actionBar.getTabCount()) {
      actionBar.setSelectedNavigationItem(selectedTabIdx);
    } else {
      actionBar.setSelectedNavigationItem(0);
    }
  }
 @Override
 public void setSelectedNavigationItem(int position) {
   mActionBar.setSelectedNavigationItem(position);
 }
 // viewpager 变化带动tab变化
 @Override
 public void onPageSelected(int position) {
   actionBar.setSelectedNavigationItem(position);
 }