本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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);
}
}
示例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());
}
}