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


Java Toolbar.inflateMenu方法代码示例

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


在下文中一共展示了Toolbar.inflateMenu方法的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);

    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

示例2: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_view_picture);
	Intent intent = getIntent();
	userHasSigned = (UserHasSigned) intent.getSerializableExtra("userHasSigned");
	faceTokenAndUrl = intent.getStringExtra("faceTokenAndUrl");
	imageView_face = (ImageView) findViewById(R.id.imageView_face);
	toolbar = (Toolbar) findViewById(R.id.toolbar_view_picture);
	toolbar.setNavigationIcon(R.mipmap.button_back);
	toolbar.setNavigationOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View view) {
			finish();
		}
	});
	toolbar.setTitle(userHasSigned.getUser_name()+"的人脸照片");
	toolbar.inflateMenu(R.menu.base_toolbar_menu);

	startViewPicture();
}
 
开发者ID:tony-Shx,项目名称:Swface,代码行数:22,代码来源:ViewPictureActivity.java

示例3: initToolbar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void initToolbar() {
    super.initToolbar();


    Toolbar toolbar = mToolbar;
    toolbar.inflateMenu(R.menu.chat_user);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.action_person) {
                onPortraitClick();
            }
            return false;
        }
    });
    // 拿到菜单Icon
    mUserInfoMenuItem = toolbar.getMenu().findItem(R.id.action_person);
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:20,代码来源:ChatUserFragment.java

示例4: initToolBar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
protected void initToolBar() {
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolBarButton = (TextView) findViewById(R.id.toolbar_button);
    if (mToolbar != null) {
        mToolbar.setTitleTextAppearance(this, R.style.ToolbarTitleAppearance);
        mToolbar.setTitle(getToolbarTitle());
        mToolbar.setNavigationIcon(R.drawable.ic_arrow_left_navbar);
        mToolbar.setNavigationOnClickListener(this);
        mToolbar.setSubtitleTextAppearance(this, R.style.ToolbarSubTitleAppearance);
        mToolbar.setSubtitleTextColor(getResources().getColor(R.color.label_grey));

        if(getToolBarMenu() != 0){
            mToolbar.inflateMenu(getToolBarMenu());
        }
        mToolbar.setTitleTextColor(getResources().getColor(R.color.white));
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:18,代码来源:SqlBaseActivity.java

示例5: onCreateView

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_todo, container, false);
  toolbar = (Toolbar) view.findViewById(R.id.toolbar);
  toolbar.setTitle(getString(R.string.title_todo));
  toolbar.inflateMenu(R.menu.todo);
  toolbar.setOnMenuItemClickListener(this);

  listView = (ListView) view.findViewById(R.id.list_view);
  refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
  adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, localTodoData);
  listView.setAdapter(adapter);
  listView.setOnItemLongClickListener(this);
  refreshLayout.setOnRefreshListener(this);

  return view;
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:19,代码来源:TodoFragment.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: onViewCreated

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    bindView(view);

    Toolbar toolbar = view.findViewById(R.id.toolbar);
    toolbar.setTitle("Detail Mahasiswa");
    toolbar.setSubtitle(mahasiswa.Nama);
    toolbar.inflateMenu(R.menu.detail_menu);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {

            switch (item.getItemId()) {
                case R.id.detail_hapus:

                    callback.onDelete(mahasiswa);
                    getDialog().dismiss();
                    break;
                case R.id.detail_edit:

                    callback.onEdit(mahasiswa);
                    getDialog().dismiss();
                    break;
            }
            return false;
        }
    });
}
 
开发者ID:alfianyusufabdullah,项目名称:android-example,代码行数:31,代码来源:DetailMahasiswaDialog.java

示例13: 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

示例14: initToolbar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public void initToolbar(Toolbar toolbar, String title, int menuRes) {
    if (toolbar != null) {
        toolbar.setTitle(title);
        toolbar.setNavigationIcon(R.drawable.ic_menu);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openOrCloseDrawer(true);
            }
        });
        toolbar.inflateMenu(menuRes);
    }
}
 
开发者ID:SirLYC,项目名称:Android-Gank-Share,代码行数:14,代码来源:MainActivity.java

示例15: 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


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