Java 类android.app.ActionBar.OnNavigationListener 实例源码

项目:like_googleplus_layout    文件:MainActivity.java   
@Override
protected void onResume()
{
    super.onResume();
    if (mIsOnlyAndroid != GoogleApplication.mIsOnlyAndroid)
    {
        initData();
        mActionBar.setListNavigationCallbacks(mAdapter, new OnNavigationListener()
        {
            public boolean onNavigationItemSelected(int itemPosition, long itemId)
            {
                SubNewsTypeItem item = (SubNewsTypeItem) mAdapter.getItem(itemPosition);
                mCurrentURL = item.url;
                if (!mIsFirstEnter)
                {
                    updateFragment();
                    mIsFirstEnter = false;
                }
                return true;
            }
        });
        mIsOnlyAndroid = GoogleApplication.mIsOnlyAndroid;
    }
}
项目:like_googleplus_layout    文件:MainActivity.java   
private void customActionBar()
{
    mActionBar = getActionBar();
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);
    mActionBar.setDisplayShowTitleEnabled(false);
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    mActionBar.setListNavigationCallbacks(mAdapter, new OnNavigationListener()
    {
        public boolean onNavigationItemSelected(int itemPosition, long itemId)
        {
            SubNewsTypeItem item = (SubNewsTypeItem) mAdapter.getItem(itemPosition);
            mCurrentURL = item.url;
            updateFragment();
            return true;
        }
    });
}
项目:android-question-answer-app    文件:MainActivity.java   
public OnNavigationListener changeSort() {
    //This is the callback that is called when the user chooses 
    //a sorting order from the spinner in the action bar.
    final Context activitycontext = this;
    return new OnNavigationListener() {
    @Override
    public boolean onNavigationItemSelected(int itemposition, long itemid) {
        // change way of sorting based on way selected
        ClientData cd = new ClientData(activitycontext);
        sortList(itemposition, dataManager, cd);
        qla.update();
        return true;

    }
};
  }
项目:like_googleplus_layout    文件:BusLineActivity.java   
public void showNavActionBar(final BusStationAdapter2 adapter)
    {
        mActionBar.setDisplayHomeAsUpEnabled(true);
        mActionBar.setHomeButtonEnabled(true);
        mIsActuralSelected = false;
        mActionBar.setDisplayShowTitleEnabled(false);
        mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        mActionBar.setListNavigationCallbacks(adapter,
            new OnNavigationListener()
            {
                public boolean onNavigationItemSelected(int itemPosition,
                    long itemId)
                {// 在这里进行切换 ,不可行 , 默认情况下会执行一次该方法
                    if (!mIsActuralSelected)
                    {
                        mIsActuralSelected = true;
                        return true;
                    }
//                  Toast.makeText(
//                      getBaseContext(),
//                      "" + itemPosition
//                          + mActionBar.getSelectedNavigationIndex(),
//                      Toast.LENGTH_SHORT).show();

                    mActionBar
                        .setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
                    BusStationItem busStationItem = (BusStationItem) adapter
                        .getItem(itemPosition);
                    beginTransaction().replace(
                        R.id.frame_container,
                        BusLineFragment2.newInstance(busStationItem.stationUrl,
                            busStationItem.busNo)).commit();
                    customActionBar(busStationItem.busNo);
                    return false;

                }
            });
    }
项目:Klyph    文件:TitledFragmentActivity.java   
@Override
public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener)
{
    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(this, array, android.R.layout.simple_dropdown_item_1line);
    list.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setListNavigationCallbacks(list, listener);
    getActionBar().setSelectedNavigationItem(position);
}
项目:Klyph    文件:TitledFragmentActivity.java   
@Override
public void displaySpinnerInActionBar(List<GraphObject> data, int position, OnNavigationListener listener)
{
    MultiObjectAdapter adapter = new MultiObjectAdapter(null, SpecialLayout.DROP_DOWN_ITEM);
    adapter.addAll(data);

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setListNavigationCallbacks(adapter, listener);
    getActionBar().setSelectedNavigationItem(position);
}
项目:Klyph    文件:TitledViewPagerActivity.java   
public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener)
{
    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(this, array, android.R.layout.simple_dropdown_item_1line);
    list.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setListNavigationCallbacks(list, listener);
    getActionBar().setSelectedNavigationItem(position);
}
项目:Klyph    文件:TitledViewPagerActivity.java   
@Override
public void displaySpinnerInActionBar(List<GraphObject> data, int position, OnNavigationListener listener)
{
    MultiObjectAdapter adapter = new MultiObjectAdapter(null, SpecialLayout.DROP_DOWN_ITEM);
    adapter.addAll(data);

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setListNavigationCallbacks(adapter, listener);
    getActionBar().setSelectedNavigationItem(position);
}
项目:Spacecurl    文件:FreePlayActivity.java   
/**
 * Creates the {@link ActionBar} and the {@link Spinner} and enables its
 * functionality
 * 
 * @see <a
 *      href="http://developer.android.com/design/patterns/actionbar.html">
 *      ActionBar Design</a>
 * @see <a
 *      href="http://developer.android.com/design/building-blocks/spinners.html">
 *      Spinner Design</a>
 */
private void setupActionbar(Bundle savedInstanceState) {
    mActionBar = getActionBar();
    mActionBar.setDisplayShowTitleEnabled(false);
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // Adapter to fill spinner with items
    List<String> gameTitles = new ArrayList<String>();
    for (GameDescription curGame : mFreeplayGames) {
        gameTitles.add(curGame.getTitle());
    }
    SpinnerAdapter spinnerAdapter = new ArrayAdapter<String>(this, R.layout.list_item_spinner,
            gameTitles);

    // Listener which calls switchToGame(position) when an item is selected
    OnNavigationListener onNavigationListener = new OnNavigationListener() {
        @Override
        public boolean onNavigationItemSelected(int position, long itemId) {
            switchToGame(position);
            return true;
        }
    };
    mActionBar.setListNavigationCallbacks(spinnerAdapter,
            onNavigationListener);

    if (savedInstanceState == null) {
        // Select first game on new start
        mActionBar.setSelectedNavigationItem(0);
    }
    else {
        // select saved game on restart
        mActionBar.setSelectedNavigationItem(
                savedInstanceState.getInt(STATE_ACTIONBAR_SELECTED_ITEM));
    }
}
项目:ChipsLibrary    文件:MainActivity.java   
@Override
protected void onCreate(final Bundle savedInstanceState)
  {
  super.onCreate(savedInstanceState);
  getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
  final ArrayList<String> itemList=new ArrayList<String>();
  itemList.add("Contacts Recipients");
  itemList.add("Customized Recipients");
  final ArrayAdapter<String> navAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,android.R.id.text1,itemList);
  getActionBar().setListNavigationCallbacks(navAdapter,new OnNavigationListener()
    {
      @Override
      public boolean onNavigationItemSelected(final int itemPosition,final long itemId)
        {
        switch(itemPosition)
          {
          case 0:
            getFragmentManager().beginTransaction().replace(android.R.id.content,new ContactsRecipientsFragment()).commit();
            break;
          case 1:
            getFragmentManager().beginTransaction().replace(android.R.id.content,new CustomRecipientFragment()).commit();
            break;
          }
        return true;
        }
    });
  }
项目:KlyphMessenger    文件:TitledFragmentActivity.java   
@Override
public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener)
{
    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(this, array, android.R.layout.simple_spinner_dropdown_item);
    list.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setListNavigationCallbacks(list, listener);
    getActionBar().setSelectedNavigationItem(position);
}
项目:cs50-final-project-android    文件:RecipeListFragment.java   
/**
 * Create the ActionBar.
 */
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.main, menu);

    mOptionsMenu = menu;

    // on change of navigation's spinner (which allows user to select category for list)
    mOnNavigationListener = new OnNavigationListener() {
        // Get the same strings provided for the drop-down's ArrayAdapter
        String[] strings = getResources().getStringArray(R.array.home_filters_list);

        @Override
        public boolean onNavigationItemSelected(int position, long itemId) {
            String selectedString = strings[position];

            Log.i(TAG, "Updating to " + selectedString);

            if (selectedString.equals("Latest")) {
                updateCategory(RecipeHelper.Category.LATEST);
            }
            if (selectedString.equals("Top Recipes")) {
                updateCategory(RecipeHelper.Category.TOP);
            }
            return true;
        }
    };

    SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.home_filters_list, android.R.layout.simple_spinner_dropdown_item);

    getActivity().getActionBar().setListNavigationCallbacks(mSpinnerAdapter,
            mOnNavigationListener);
}
项目:evercam-play-android2    文件:VideoActivity.java   
private void loadCamerasToActionBar()
{
    String[] cameraNames;

    final ArrayList<EvercamCamera> onlineCameraList = new ArrayList<>();
    final ArrayList<EvercamCamera> cameraList;

    //If is not showing offline cameras, the offline cameras should be excluded from list
    if(PrefsManager.showOfflineCameras(VideoActivity.this))
    {
        cameraList = AppData.evercamCameraList;
    }
    else
    {
        for(EvercamCamera evercamCamera : AppData.evercamCameraList)
        {
            if(!evercamCamera.isOffline())
            {
                onlineCameraList.add(evercamCamera);
            }
        }

        cameraList = onlineCameraList;
    }

    cameraNames = getCameraNameArray(cameraList);

    CameraListAdapter adapter = new CameraListAdapter(VideoActivity.this,
            R.layout.live_view_spinner, R.id.spinner_camera_name_text, cameraNames, cameraList);
    VideoActivity.this.getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    OnNavigationListener navigationListener = new OnNavigationListener()
    {
        @Override
        public boolean onNavigationItemSelected(int itemPosition, long itemId)
        {
            //Stop time counter when another camera selected
            if(timeCounter != null)
            {
                timeCounter.stop();
                timeCounter = null;
            }

            if(browseJpgTask != null && browseJpgTask.getStatus() != AsyncTask.Status.RUNNING)
            {
                browseJpgTask.cancel(true);
            }
            browseJpgTask = null;
            showImagesVideo = false;

            evercamCamera = cameraList.get(itemPosition);


            if(evercamCamera.isOffline())
            {
                // If camera is offline, show offline msg and stop video
                // playing.
                offlineTextView.setVisibility(View.VISIBLE);
                progressView.setVisibility(View.GONE);

                // Hide video elements if switch to an offline camera.
                surfaceView.setVisibility(View.GONE);
                imageView.setVisibility(View.GONE);
            }
            else
            {
                offlineTextView.setVisibility(View.GONE);

                setCameraForPlaying(cameraList.get(itemPosition));
                createPlayer(evercamCamera);
            }
            return false;
        }
    };

    getActionBar().setListNavigationCallbacks(adapter, navigationListener);
    getActionBar().setSelectedNavigationItem(defaultCameraIndex);
}
项目:AugmentedOxford    文件:TourListFragment.java   
private void createSortingDropdown() {
    // create spinner adapter
    ArrayAdapter<CharSequence> mSpinnerAdapter = ArrayAdapter.createFromResource(
            getActivity(), R.array.sorting_criteria_list, R.layout.custom_spinner_dropdown_item); //or android.R.layout.simple_spinner..
    mSpinnerAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item);

    // create navigation listener
    mOnNavigationListener = new OnNavigationListener() {
          // Get the same strings provided for the drop-down's ArrayAdapter
          String[] strings = getResources().getStringArray(R.array.sorting_criteria_list);

          // action when selected.
          @Override
          public boolean onNavigationItemSelected(int position, long itemId) {
              // change sorting criterion and refresh as required
              /*
              switch (strings[position]) {
              case "Alphabetical":
                  sortOrder = strings[position];
                  refresh();
                  break;
              case "Proximity":
                  sortOrder = strings[position];
                  refresh();
                  break;
              default: 
                  sortOrder = "Filename";
                  refresh();
                  break;
              }
              */
              sortOrder = strings[position];
              refresh();
              Toast.makeText(getActivity(), "Tour sort order: " + strings[position], Toast.LENGTH_SHORT).show();
              return true;
          }
    };

    // assign to action bar
    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

}
项目:MistaReader    文件:DropDownNav.java   
public void reBuildSubmenu(Activity mainActivity, String selectedForumName, int selectedSectionPosition) {

        final ActionBar actionBar = mainActivity.getActionBar();

        if (selectedForumName.isEmpty()) {
            setDefaultActionBarMode(actionBar);
            actionBar.setTitle(R.string.sAllSections);
            return;
        }
        else if (selectedForumName.equals(NavDrawer_Main.MENU_SUBSCRIPTIONS)) {
            setDefaultActionBarMode(actionBar);
            actionBar.setTitle(R.string.sSubscriptions);
            return;
        }

        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

        ArrayList<String> dropdownItems = new ArrayList<String>();

        if (selectedForumName.equals(API.TOPICS_WITH_ME)) {

            dropdownItems.add(mainActivity.getString(R.string.sMyTopics2));
            dropdownItems.add(mainActivity.getString(R.string.sMyTopics));

        }
        else
        {
            final Resources locRes = mainActivity.getResources();

            shortSectionsNamesList = new ArrayList<String>();

            dropdownItems.add(selectedForumName + " (" + locRes.getText(string.sNavDrawerAll) + ")");
            shortSectionsNamesList.add(selectedForumName);

            Forum forum = Forum.getInstance();

            for (int i = 0; i < forum.sections.size(); i++) {

                Section sec = forum.sections.get(i);
                if (sec.forumName.equals(selectedForumName)) {
                    dropdownItems.add(sec.sectionFullName);
                    shortSectionsNamesList.add(sec.sectionShortName);
                }

            }
        }

        ArrayAdapter<String> aAdpt = new ArrayAdapter<String>(mainActivity, R.layout.actionbar_dropdowntext, android.R.id.text1, dropdownItems);
        aAdpt.setDropDownViewResource(android.R.layout.simple_list_item_1);

        actionBar.setListNavigationCallbacks(aAdpt, (OnNavigationListener) mainActivity);

        actionBar.setSelectedNavigationItem(selectedSectionPosition);

    }
项目:GAnalytics    文件:MainActivity.java   
private void setNavigationList(String accountName)
{
    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setDisplayShowTitleEnabled(false);

    ArrayList<String> navItems = getAccountsList();
    navItems.add("Add Account");

    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActionBar().getThemedContext(), R.layout.spinner_item, navItems);
    adapter.setDropDownViewResource(R.layout.spinner_item_dropdown);

    getActionBar().setListNavigationCallbacks(adapter, new OnNavigationListener()
    {

        @Override
        public boolean onNavigationItemSelected(int itemPosition, long itemId)
        {
            String selItem = adapter.getItem(itemPosition);

            if (selItem.equals("Add Account"))
            {
                startAddGoogleAccountIntent();
                return true;
            }

            if (getAccountsList().size() >= itemPosition)
            {
                if (App.LOCAL_LOGV)
                    Log.v(App.TAG, "Fetching accounts for:"
                            + getAccountsList().get(itemPosition));

                credential.setSelectedAccountName(getAccountsList().get(itemPosition));

                analytics_service = getAnalyticsService(credential);
                if (analytics_service == null)
                    Log.e(App.TAG, "analytics service is null");

                if (mBound)
                    unbindService(mConnection);

                getAnalyticsAccounts();
            }

            return true;
        }
    });

    if (accountName != null)
    {
        int index = navItems.indexOf(accountName);
        if (index != -1)
            getActionBar().setSelectedNavigationItem(index);
        else
            Log.e(App.TAG, "acount not found");
    }
}
项目:Klyph    文件:IActionbarSpinner.java   
public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener);
项目:Klyph    文件:IActionbarSpinner.java   
public void displaySpinnerInActionBar(List<GraphObject> data, int position, OnNavigationListener listener);
项目:KlyphMessenger    文件:IActionbarSpinner.java   
public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener);