本文整理汇总了Java中android.app.ActionBar.OnNavigationListener类的典型用法代码示例。如果您正苦于以下问题:Java OnNavigationListener类的具体用法?Java OnNavigationListener怎么用?Java OnNavigationListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnNavigationListener类属于android.app.ActionBar包,在下文中一共展示了OnNavigationListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResume
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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;
}
}
示例2: customActionBar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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;
}
});
}
示例3: changeSort
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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;
}
};
}
示例4: showNavActionBar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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;
}
});
}
示例5: displaySpinnerInActionBar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例6: displaySpinnerInActionBar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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);
}
示例7: setupActionbar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
/**
* 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));
}
}
示例8: onCreate
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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;
}
});
}
示例9: displaySpinnerInActionBar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
@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);
}
示例10: onCreateOptionsMenu
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
/**
* 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);
}
示例11: loadCamerasToActionBar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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);
}
示例12: createSortingDropdown
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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);
}
示例13: reBuildSubmenu
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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);
}
示例14: setNavigationList
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
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");
}
}
示例15: displaySpinnerInActionBar
import android.app.ActionBar.OnNavigationListener; //导入依赖的package包/类
public void displaySpinnerInActionBar(int array, int position, OnNavigationListener listener);