Java Code Examples for android.support.v7.app.ActionBar.OnNavigationListener

The following are top voted examples for showing how to use android.support.v7.app.ActionBar.OnNavigationListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: boohee_v5.6   File: ToolbarActionBar.java   View source code 4 votes vote down vote up
public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
    this.mDecorToolbar.setDropdownParams(adapter, new NavItemSelectedListener(callback));
}
 
Example 2
Project: boohee_v5.6   File: NavItemSelectedListener.java   View source code 4 votes vote down vote up
public NavItemSelectedListener(OnNavigationListener listener) {
    this.mListener = listener;
}
 
Example 3
Project: boohee_v5.6   File: WindowDecorActionBar.java   View source code 4 votes vote down vote up
public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
    this.mDecorToolbar.setDropdownParams(adapter, new NavItemSelectedListener(callback));
}
 
Example 4
Project: btc-e-assist   File: FinancesActivity.java   View source code 4 votes vote down vote up
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    mSavedState = savedState;
    setContentView(R.layout.activity_standard_fragment);
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.finances_tabs_names, R.layout.item_actionbar_spinner);
    ActionBar.OnNavigationListener mOnNavigationListener = new OnNavigationListener() {
        String[] tabNames = getResources().getStringArray(
                R.array.finances_tabs_names);

        @Override
        public boolean onNavigationItemSelected(int position, long rowId) {
            if (mSavedState != null) {
                int savedPosition = mSavedState.getInt(
                        BUNDLE_POSITION_NAME, Integer.MIN_VALUE);
                if (savedPosition != Integer.MIN_VALUE) {
                    mSavedState.putInt(BUNDLE_POSITION_NAME,
                            Integer.MIN_VALUE);
                    actionBar.setSelectedNavigationItem(savedPosition);
                    return false;
                } else {
                    if (previousPosition == position) {
                        return false;
                    }
                }
            }
            FragmentTransaction ft = getSupportFragmentManager()
                    .beginTransaction();
            switch (position) {
                case 0:
                    ft.replace(R.id.standardLayout, new BalanceFragment(),
                            tabNames[position]);
                    break;
                case 1:
                    ft.replace(R.id.standardLayout, new MyTradeFragment(),
                            tabNames[position]);
                    break;
                case 2:
                    ft.replace(R.id.standardLayout, new MyTransFragment(),
                            tabNames[position]);
                    break;
            }
            ft.commit();
            previousPosition = position;
            return true;
        }
    };
    actionBar.setListNavigationCallbacks(mSpinnerAdapter,
            mOnNavigationListener);
}
 
Example 5
Project: btc-e-assist   File: ChatActivity.java   View source code 4 votes vote down vote up
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    mSavedState = savedState;
    setContentView(R.layout.activity_standard_fragment);
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.chat_tabs_names, R.layout.item_actionbar_spinner);
    ActionBar.OnNavigationListener mOnNavigationListener = new OnNavigationListener() {
        String[] tabNames = getResources().getStringArray(
                R.array.chat_tabs_names);

        @Override
        public boolean onNavigationItemSelected(int position, long rowId) {
            if (mSavedState != null) {
                int savedPosition = mSavedState.getInt(
                        BUNDLE_POSITION_NAME, Integer.MIN_VALUE);
                if (savedPosition != Integer.MIN_VALUE) {
                    mSavedState.putInt(BUNDLE_POSITION_NAME,
                            Integer.MIN_VALUE);
                    actionBar.setSelectedNavigationItem(savedPosition);
                    return false;
                } else {
                    if (previousPosition == position) {
                        return false;
                    }
                }
            }
            FragmentTransaction ft = getSupportFragmentManager()
                    .beginTransaction();
            switch (position) {
                case 0:
                    ft.replace(R.id.standardLayout, new ChatFragment(),
                            tabNames[position]);
                    break;
                case 1:
                    ft.replace(R.id.standardLayout, new NewsFragment(),
                            tabNames[position]);
                    break;
            }
            ft.commit();
            previousPosition = position;
            return true;
        }
    };
    actionBar.setListNavigationCallbacks(mSpinnerAdapter,
            mOnNavigationListener);
}
 
Example 6
Project: btc-e-assist   File: ProfileActivity.java   View source code 4 votes vote down vote up
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    mSavedState = savedState;
    setContentView(R.layout.activity_standard_fragment);
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.profile_tabs_names, R.layout.item_actionbar_spinner);
    ActionBar.OnNavigationListener mOnNavigationListener = new OnNavigationListener() {
        String[] tabNames = getResources().getStringArray(
                R.array.profile_tabs_names);

        @Override
        public boolean onNavigationItemSelected(int position, long rowId) {
            if (mSavedState != null) {
                int savedPosition = mSavedState.getInt(
                        BUNDLE_POSITION_NAME, Integer.MIN_VALUE);
                if (savedPosition != Integer.MIN_VALUE) {
                    mSavedState.putInt(BUNDLE_POSITION_NAME,
                            Integer.MIN_VALUE);
                    actionBar.setSelectedNavigationItem(savedPosition);
                    return false;
                } else {
                    if (previousPosition == position) {
                        return false;
                    }
                }
            }
            FragmentTransaction ft = getSupportFragmentManager()
                    .beginTransaction();
            switch (position) {
                case 0:
                    ft.replace(R.id.standardLayout, new AddProfileFragment(),
                            tabNames[position]);
                    break;
                case 1:
                    ft.replace(R.id.standardLayout,
                            new SelectProfileFragment(), tabNames[position]);
                    break;
            }
            ft.commit();
            previousPosition = position;
            return true;
        }
    };
    actionBar.setListNavigationCallbacks(mSpinnerAdapter,
            mOnNavigationListener);
}
 
Example 7
Project: btc-e-assist   File: TickerActivity.java   View source code 4 votes vote down vote up
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    mSavedState = savedState;
    setContentView(R.layout.activity_standard_fragment);
    fragmentManager = getSupportFragmentManager();
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.ticker_tabs_names, R.layout.item_actionbar_spinner);
    ActionBar.OnNavigationListener mOnNavigationListener = new OnNavigationListener() {
        String[] tabNames = getResources().getStringArray(
                R.array.ticker_tabs_names);

        @Override
        public boolean onNavigationItemSelected(int position, long rowId) {
            if (mSavedState != null) {
                int savedPosition = mSavedState.getInt(
                        BUNDLE_POSITION_NAME, Integer.MIN_VALUE);
                if (savedPosition != Integer.MIN_VALUE) {
                    mSavedState.putInt(BUNDLE_POSITION_NAME,
                            Integer.MIN_VALUE);
                    actionBar.setSelectedNavigationItem(savedPosition);
                    return false;
                } else {
                    if (previousPosition == position) {
                        return false;
                    }
                }
            }
            FragmentTransaction ft = fragmentManager.beginTransaction();
            switch (position) {
                case 0:
                    ft.replace(R.id.standardLayout, new TickerFragment(),
                            tabNames[position]);
                    break;
                case 1:
                    ft.replace(R.id.standardLayout, new OrdersFragment(),
                            tabNames[position]);
                    break;
                case 2:
                    ft.replace(R.id.standardLayout, new TradesFragment(),
                            tabNames[position]);
                    break;
            }
            ft.commit();
            previousPosition = position;
            return true;
        }
    };
    actionBar.setListNavigationCallbacks(mSpinnerAdapter,
            mOnNavigationListener);
}
 
Example 8
Project: btc-e-assist   File: AssistActivity.java   View source code 4 votes vote down vote up
@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    mSavedState = savedState;
    setContentView(R.layout.activity_standard_fragment);
    actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.assist_tabs_names, R.layout.item_actionbar_spinner);
    ActionBar.OnNavigationListener mOnNavigationListener = new OnNavigationListener() {
        String[] tabNames = getResources().getStringArray(
                R.array.assist_tabs_names);

        @Override
        public boolean onNavigationItemSelected(int position, long rowId) {
            if (mSavedState != null) {
                int savedPosition = mSavedState.getInt(
                        BUNDLE_POSITION_NAME, Integer.MIN_VALUE);
                if (savedPosition != Integer.MIN_VALUE) {
                    mSavedState.putInt(BUNDLE_POSITION_NAME,
                            Integer.MIN_VALUE);
                    actionBar.setSelectedNavigationItem(savedPosition);
                    return false;
                } else {
                    if (previousPosition == position) {
                        return false;
                    }
                }
            }
            FragmentTransaction ft = getSupportFragmentManager()
                    .beginTransaction();
            switch (position) {
                case 0:
                    ft.replace(R.id.standardLayout, new AssistAlarmFragment(),
                            tabNames[position]);
                    break;
                case 1:
                    ft.replace(R.id.standardLayout, new AssistTasksFragment(),
                            tabNames[position]);
                    break;
            }
            ft.commit();
            previousPosition = position;
            return true;
        }
    };
    actionBar.setListNavigationCallbacks(mSpinnerAdapter,
            mOnNavigationListener);
}
 
Example 9
Project: gloomy-dungeons-2   File: ActionBarView.java   View source code 4 votes vote down vote up
public void setCallback(OnNavigationListener callback) {
    mCallback = callback;
}
 
Example 10
Project: WATCHiT   File: RealityCheckActivity.java   View source code 4 votes vote down vote up
@Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_reality_check);
       
       mActionBar = getSupportActionBar();
       mActionBar.setDisplayHomeAsUpEnabled(true);
       mActionBar.setDisplayShowTitleEnabled(false);
       mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
       
       final String[] dropdownValues = getResources().getStringArray(R.array.reality_check_items_array);;

       // Specify a SpinnerAdapter to populate the dropdown list.
       ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActionBar.getThemedContext(), android.R.layout.simple_spinner_item, android.R.id.text1, dropdownValues);

       adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

       // Set up the dropdown list navigation in the action bar.
       mActionBar.setListNavigationCallbacks(adapter, new OnNavigationListener() {

		@Override
		public boolean onNavigationItemSelected(int position, long itemId) {
			switch (position) {
				case 0:
					RealityCheckListAdapter stepListAdapter = new RealityCheckListAdapter(RealityCheckActivity.this, R.layout.list_item_step_reality_check, mProcedure.getSteps());
			        mListView.setAdapter(stepListAdapter);
					break;
				case 1:
					CompareListAdapter step1ListAdapter = new CompareListAdapter(RealityCheckActivity.this, R.layout.list_item_step_compare, mProcedure.getSteps());
			        mListView.setAdapter(step1ListAdapter);
					break;
			}
			return true;
		}
       	
       });
       
       mProcedure = getIntent().getParcelableExtra("procedure");
       
       mListView = (ListView) findViewById(R.id.listView);
}
 
Example 11
Project: SupportLibraryV7AppCompatPatched   File: ActionBarView.java   View source code 4 votes vote down vote up
public void setCallback(OnNavigationListener callback) {
    mCallback = callback;
}
 
Example 12
Project: SupportLibraryV7AppCompatPatched   File: ActionBarView.java   View source code 4 votes vote down vote up
public void setCallback(OnNavigationListener callback) {
    mCallback = callback;
}
 
Example 13
Project: TeamboxClient   File: TasksListFragment.java   View source code 4 votes vote down vote up
private void setupActionBar() {
	// Set up the action bar to show a dropdown list.
	final ActionBar actionBar = ((MainActivity) getActivity())
			.getSupportActionBar();
	actionBar.setDisplayShowTitleEnabled(false);
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

	// Specify a SpinnerAdapter to populate the dropdown list.
	mDropDownAdapter = new DropDrownProjectsListAdapter(
			actionBar.getThemedContext(),
			android.R.layout.simple_spinner_item,
			mInfoToLoadAtDropDownListOfActionBar);

	OnNavigationListener listener = new OnNavigationListener() {

		@Override
		public boolean onNavigationItemSelected(int position, long id) {
			// When the Navigation mode is activated, the source of
			// DropDownList (mInfoToLoadAtDropDownListOfActionBar) is empty,
			// because it is populate in an asynctask.
			// This condition must be check to avoid error.
			if (isDropDownListLoaded()) {
				mProjectIdToFilter = mInfoToLoadAtDropDownListOfActionBar
						.get(position).projectId;
				mLoadDataInListViewAsyncTask = new LoadDataInListViewAsyncTask();
				mLoadDataInListViewAsyncTask.execute(mProjectIdToFilter,
						Application
								.getTaskPriorityFilterValue(getActivity()));
			}
			return true;
		}
	};

	// Set up the dropdown list navigation in the action bar.
	actionBar.setListNavigationCallbacks(mDropDownAdapter, listener);

	// use getActionBar().getThemedContext() to ensure
	// that the text color is always appropriate for the action bar
	// background rather than the activity background.

}