当前位置: 首页>>代码示例>>Java>>正文


Java Toolbar.setOnMenuItemClickListener方法代码示例

本文整理汇总了Java中android.support.v7.widget.Toolbar.setOnMenuItemClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.setOnMenuItemClickListener方法的具体用法?Java Toolbar.setOnMenuItemClickListener怎么用?Java Toolbar.setOnMenuItemClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.Toolbar的用法示例。


在下文中一共展示了Toolbar.setOnMenuItemClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

  // App Logo
  toolbar.setLogo(R.drawable.ic_launcher);
  // Title
  toolbar.setTitle("My Title");
  // Sub Title
  toolbar.setSubtitle("Sub title");

  setSupportActionBar(toolbar);

  // Navigation Icon 要設定在 setSupoortActionBar 才有作用
  // 否則會出現 back bottom
  toolbar.setNavigationIcon(R.drawable.ab_android);
  // Menu item click 的監聽事件一樣要設定在 setSupportActionBar 才有作用
  toolbar.setOnMenuItemClickListener(onMenuItemClick);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:MainActivity.java

示例2: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.main);
    toolbar.setOnMenuItemClickListener(this);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setHasFixedSize(true);

    if (savedInstanceState == null) {
        mHorizontal = true;
    } else {
        mHorizontal = savedInstanceState.getBoolean(ORIENTATION);
    }

    setupAdapter();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:MainActivity.java

示例3: setupHeaderView

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void setupHeaderView() {
	final Toolbar toolbar = new Toolbar(this);
	getMenuInflater().inflate(R.menu.header_menu, toolbar.getMenu());
	toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(final MenuItem item) {
			handleToolbarItemClick(item);
			return true;
		}
	});

	header = new ToolbarHeader(this);
	header.setToolbar(toolbar);
	header.setBackgroundColor(Color.WHITE);

	final Bitmap defaultArtwork = BitmapFactory.decodeResource(getResources(), R.raw
			.default_artwork);
	final DisplayableDefaults defaults = new ImmutableDisplayableDefaults("Playlist",
			"Unknown artists",
			new BitmapDrawable(getResources(), defaultArtwork));

	header.setTitleDataBinder(new TitleBinder(headerTitleCache, defaults));
	header.setSubtitleDataBinder(new SubtitleBinder(headerSubtitleCache, defaults));
	header.setArtworkDataBinder(new ArtworkBinder(headerArtworkCache, defaults));
}
 
开发者ID:MatthewTamlin,项目名称:Mixtape,代码行数:26,代码来源:PlaylistActivity.java

示例4: inflateToolbarMenu

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
/**
 * Inflates the menu of the toolbar, which is shown, when the tab switcher is shown.
 */
private void inflateToolbarMenu() {
    Toolbar[] toolbars = getToolbars();
    int menuId = getModel().getToolbarMenuId();

    if (toolbars != null && menuId != -1) {
        Toolbar toolbar = toolbars.length > 1 ? toolbars[1] : toolbars[0];
        toolbar.inflateMenu(menuId);
        toolbar.setOnMenuItemClickListener(getModel().getToolbarMenuItemListener());
    }
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:14,代码来源:AbstractTabSwitcherLayout.java

示例5: onCreateView

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_tab_layout, container, false);

        mTableLayout = (AdaptiveTableLayout) view.findViewById(R.id.tableLayout);
        progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
        vHandler = view.findViewById(R.id.vHandler);

        Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().onBackPressed();
            }
        });
        toolbar.inflateMenu(R.menu.table_layout);
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                if (item.getItemId() == R.id.actionSave) {
                    applyChanges();
                } else if (item.getItemId() == R.id.actionSettings) {
                    SettingsDialog.newInstance(
                            mTableLayout.isHeaderFixed(),
                            mTableLayout.isSolidRowHeader(),
                            mTableLayout.isRTL(),
                            mTableLayout.isDragAndDropEnabled())
                            .show(getChildFragmentManager(), SettingsDialog.class.getSimpleName());
                }
                return true;
            }
        });
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//            mTableLayout.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
        }
        initAdapter();

        return view;
    }
 
开发者ID:Cleveroad,项目名称:AdaptiveTableLayout,代码行数:41,代码来源:TableLayoutFragment.java

示例6: onCreateOptionsMenu

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // Add the search button to the toolbar.
    Toolbar toolbar = getActionBarToolbar();
    toolbar.inflateMenu(R.menu.explore_io_menu);
    toolbar.setOnMenuItemClickListener(this);
    return true;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:11,代码来源:ExploreIOActivity.java

示例7: setupView

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void setupView() {
    createPoiFeature = (TextView) getActivity().findViewById(R.id.createPoiFeature);
    createPoiFeature.setOnClickListener(clickListener);
    createName = (EditText) getActivity().findViewById(R.id.createName);
    createStreet = (EditText) getActivity().findViewById(R.id.createStreet);
    createHouseNumber = (EditText) getActivity().findViewById(R.id.createHouseNumber);
    createPostCode = (EditText) getActivity().findViewById(R.id.createPostCode);
    createCity = (EditText) getActivity().findViewById(R.id.createCity);
    createPhone = (EditText) getActivity().findViewById(R.id.createPhone);
    createWebsite = (EditText) getActivity().findViewById(R.id.createWebsite);
    createEmail = (EditText) getActivity().findViewById(R.id.createEmail);
    createInternetContainer = (LinearLayout) getActivity().findViewById(R.id.createInternetContainer);
    createInternet = (Spinner) getActivity().findViewById(R.id.createInternet);
    dropdownItems = new String[]{"", getString(R.string.yes), getString(R.string.no), getString(R.string.wifi), getString(R.string.wired), getString(R.string.wlan)};
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, dropdownItems);
    createInternet.setAdapter(adapter);

    TextView osmCopyright = (TextView) getActivity().findViewById(R.id.osmCopyrightCreatePoi);
    osmCopyright.setText(Html.fromHtml(getString(R.string.osm_copyright)));
    toolbar = (Toolbar) getActivity().findViewById(R.id.createPoiToolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener()

    {
        @Override
        public void onClick(View v) {
            closeFragment();
        }
    });
    toolbar.inflateMenu(R.menu.update_poi);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (!allFieldsValid()) return true;
            createPoi();
            return true;
        }
    });
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:39,代码来源:CreatePoiFragment.java

示例8: initView

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void initView() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setTe = (TextView) findViewById(R.id.receive);
    onLineListView = (RecyclerView) findViewById(R.id.online_list);
    onlineRecyclerAdapter = new OnlineRecyclerAdapter();
    onlineRecyclerAdapter.setOnItemClickListener(new OnlineRecyclerAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position, final OnlineModel onlineModel) {
            Toast.makeText(App.context, "发送消息 desIp=" + onlineModel.getSourceIp(), Toast.LENGTH_SHORT).show();
            SendOperation.getInstance().sendMessage(MessageModel.createMessage(MessageModel.SEND_INFO, onlineModel.getSourceIp(),
                    new SendInfo().getJsonString()), 10);
        }
    });
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);

    onLineListView.setLayoutManager(layoutManager);
    onLineListView.setItemAnimator(new DefaultItemAnimator());
    onLineListView.setAdapter(onlineRecyclerAdapter);

    toolbar.inflateMenu(R.menu.base_toolbar_menu);

    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {

            int menuId = item.getItemId();
            if (menuId == R.id.action_setting) {
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                intent.setType("*/*");
                intent.addCategory(Intent.CATEGORY_OPENABLE);
                try {
                    startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), 0xaa);
                } catch (android.content.ActivityNotFoundException ex) {
                }
            }

            return true;
        }
    });
}
 
开发者ID:ANDROIDTODO,项目名称:Transmission,代码行数:41,代码来源:MainActivity.java

示例9: onCreateOptionsMenu

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // Add the filter & search buttons to the toolbar.
    Toolbar toolbar = getActionBarToolbar();
    toolbar.inflateMenu(R.menu.explore_sessions_filtered);
    toolbar.setOnMenuItemClickListener(this);
    return true;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:11,代码来源:ExploreSessionsActivity.java

示例10: onCreateView

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        mContext = getContext();

        View rootView = inflater.inflate(R.layout.fragment_profile, container, false);

        mToolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
        mToolbar.inflateMenu(R.menu.menu_profile);
        mToolbar.setOnMenuItemClickListener(this);

        mImageProfile = (CircleImageView) rootView.findViewById(R.id.image_profile);
        mTextViewFullName = (TextView) rootView.findViewById(R.id.text_fullname);

        Glide.with(mContext).load(Quire.userProfilePic).into(mImageProfile);
        mTextViewFullName.setText(Quire.name);

        mImageUpload = (ImageView) rootView.findViewById(R.id.image_one);
        mImageUpload.setOnClickListener(this);

        mButtonListNewItem = (Button) rootView.findViewById(R.id.button_list_new_item);
        mButtonListNewItem.setOnClickListener(this);

        mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
        mRecyclerView.setHasFixedSize(true);

        userListingsAdapter = new UserListingsAdapter(mContext, userListingsData());
        mRecyclerView.setAdapter(userListingsAdapter);

        mLayoutManager = new GridLayoutManager(mContext, 3);
//        mLayoutManager = new LinearLayoutManager(mContext);
        mRecyclerView.setLayoutManager(mLayoutManager);

        return rootView;
    }
 
开发者ID:narenkukreja,项目名称:quire,代码行数:37,代码来源:ProfileFragment.java

示例11: initToolBar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
/**
 * 初始化toolbar
 */
private void initToolBar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.tb_bar);
    toolbar.setTitleTextColor(Color.WHITE);
    toolbar.setTitle("状态切换");
    toolbar.inflateMenu(R.menu.base_toolbar_menu);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if(item.getItemId() == R.id.action_contents) {
                showContent();
            }
            if(item.getItemId() == R.id.action_emptyData) {
                showEmptyData();
            }
            if(item.getItemId() == R.id.action_error) {
                showError();
            }
            if(item.getItemId() == R.id.action_networkError) {
                showNetWorkError();
            }
            if(item.getItemId() == R.id.action_loading) {
                showLoading();
            }
            return true;
        }
    });
}
 
开发者ID:yangchong211,项目名称:YCStateLayout,代码行数:31,代码来源:BaseActivity.java

示例12: initToolBar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void initToolBar(Toolbar toolbarDoubanDetail, String title) {
    setSupportActionBar(toolbarDoubanDetail);
    toolbarDoubanDetail.setTitle(title);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //去除默认Title显示
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.mipmap.icon_back);
    }
    toolbarDoubanDetail.setTitleTextColor(Color.WHITE);
    toolbarDoubanDetail.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });
    toolbarDoubanDetail.setTitleTextAppearance(this, R.style.ToolBar_Title);
    toolbarDoubanDetail.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitle);
    toolbarDoubanDetail.inflateMenu(R.menu.base_header_menu);
    toolbarDoubanDetail.setOverflowIcon(getDrawable(R.mipmap.actionbar_more));
    toolbarDoubanDetail.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.actionbar_more:// 更多信息
                    setTitleClickMore();
                    break;
            }
            return true;
        }
    });
}
 
开发者ID:paterWang,项目名称:EasyReader,代码行数:34,代码来源:MovieTopDetailActivity.java

示例13: initView

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override protected void initView(View parent) {
  requestBaseInit(getPageTitle());
  mRecyclerView = (RecyclerView) parent.findViewById(R.id.recyclerView);
  Toolbar toolbar = getToolBar();
  toolbar.inflateMenu(R.menu.main);
  toolbar.setBackgroundResource(R.color.main_color_normal);
  toolbar.setOnMenuItemClickListener(this);
  mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
  mRecyclerView.setHasFixedSize(true);

  setupAdapter();
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:13,代码来源:RecyclerViewSnapUI.java

示例14: getSelectorModeToolbar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
static Toolbar getSelectorModeToolbar(Context context,
                                      View.OnClickListener onClickListener,
                                      Toolbar.OnMenuItemClickListener onItemClickListener) {
    final Toolbar toolbar = new Toolbar(context);
    toolbar.setTag(SELECTOR_TOOLBAR_TAG);

    Theme theme = Settings.getInstance(context).getThemeInstance(context);
    int accentColor = theme.getAccentColor(context);
    int accentTextColor = theme.getAccentTextColor(context);

    toolbar.setBackgroundColor(accentColor);

    toolbar.setTitleTextColor(accentTextColor);

    toolbar.inflateMenu(R.menu.selector_mode);
    toolbar.setOnMenuItemClickListener(onItemClickListener);

    Drawable menuIcon = toolbar.getOverflowIcon();
    if (menuIcon != null) {
        DrawableCompat.wrap(menuIcon);
        DrawableCompat.setTint(menuIcon.mutate(), accentTextColor);
    }

    Drawable navIcon = ContextCompat.getDrawable(context,
            R.drawable.ic_clear_black_24dp);
    if (navIcon != null) {
        DrawableCompat.wrap(navIcon);
        DrawableCompat.setTint(navIcon.mutate(), accentTextColor);
        toolbar.setNavigationIcon(navIcon);
    }

    toolbar.setNavigationOnClickListener(onClickListener);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        toolbar.setElevation(context.getResources()
                .getDimension(R.dimen.toolbar_elevation));
    }
    return toolbar;
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:40,代码来源:NestedRecyclerViewAlbumHolder.java

示例15: requestFullScreenIfLandscape

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void requestFullScreenIfLandscape() {
    if (getResources().getBoolean(R.bool.landscape)) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN);
    } else {
        Toolbar toolbar = findViewById(R.id.toolbar);
        toolbar.inflateMenu(R.menu.main);
        toolbar.setOnMenuItemClickListener(this);
    }
}
 
开发者ID:rubensousa,项目名称:PreviewSeekBar,代码行数:15,代码来源:MainActivity.java


注:本文中的android.support.v7.widget.Toolbar.setOnMenuItemClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。