本文整理汇总了Java中android.support.v7.app.ActionBar.OnNavigationListener类的典型用法代码示例。如果您正苦于以下问题:Java OnNavigationListener类的具体用法?Java OnNavigationListener怎么用?Java OnNavigationListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnNavigationListener类属于android.support.v7.app.ActionBar包,在下文中一共展示了OnNavigationListener类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setListNavigationCallbacks
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
public void setListNavigationCallbacks(SpinnerAdapter adapter, OnNavigationListener callback) {
this.mDecorToolbar.setDropdownParams(adapter, new NavItemSelectedListener(callback));
}
示例2: NavItemSelectedListener
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
public NavItemSelectedListener(OnNavigationListener listener) {
this.mListener = listener;
}
示例3: onCreate
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例4: onCreate
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例5: onCreate
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例6: onCreate
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例7: onCreate
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例8: setCallback
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
public void setCallback(OnNavigationListener callback) {
mCallback = callback;
}
示例9: onCreate
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例10: setupActionBar
import android.support.v7.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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.
}