jjzjj

MenuItemCompat

全部标签

android - MenuItemCompat.getActionView 返回 Null

我正在尝试为我的菜单项实现自定义布局并通过许多解决方案,每当我尝试在为我的menuItem的actionLayout指定的布局中获取TextView时,我都会收到NullpointerExceptiongetActionView返回null。主菜单:counter_action_bar_notification_icon主要Activity:@OverridepublicbooleanonCreateOptionsMenu(Menumenu){MenuInflaterinflater=getMenuInflater();inflater.inflate(R.menu.home_menu

android - 即使我正在使用 MenuItemCompat.setOnActionExpandListener 我的应用程序也会崩溃,建议使用 MenuItemCompat.setOnActionExpandListener

这个问题在这里已经有了答案:AndroidSupportRepo46.0.0withAndroidStudio2.3(7个答案)关闭5年前。今天AndroidStudio(设置为稳定channel更新)让我下载Android支持存储库46.0.0的更新,所以我照做了。然后突然之间,我们的应用程序每次都开始崩溃,因为MenuItemCompat.setOnActionExpandListener。是的,我应该查看发行说明,但我没有-这是事实。现在我们的问题是什么-即使我们使用推荐的符号MenuItemCompat.setOnActionExpandListener,我们的应用程序崩溃了,

android - 使用 MenuItemCompat 获取 SearchView (Android)

我正在尝试按照Android开发人员的说法实现SearchViewActionBar项目,但我遇到了一些麻烦。(http://developer.android.com/guide/topics/ui/actionbar.html)。有两个错误,我找了很多都没有找到解决办法。1)我对类MenuItemCompat有疑问。它说:MenuItemCompat类型未定义方法getActionView(MenuItem)我只能为这个类使用以下方法:setShowAsAction(item,actionEnum)setActionView(项目,View)这是代码@Overridepublicb

android - java.lang.UnsupportedOperationException : This is not supported, 使用 MenuItemCompat.setOnActionExpandListener()

我最近从Eclipse迁移到AndroidStudio,在这样做时我发现了以下错误java.lang.UnsupportedOperationException:Thisisnotsupported,useMenuItemCompat.setOnActionExpandListener()atandroid.support.v7.internal.view.menu.MenuItemImpl.setOnActionExpandListener(MenuItemImpl.java:740)atbiz.nickbullcomputing.bevnav.MainActivity.onCrea

android - java.lang.UnsupportedOperationException : This is not supported, 使用 MenuItemCompat.setOnActionExpandListener()

我最近从Eclipse迁移到AndroidStudio,在这样做时我发现了以下错误java.lang.UnsupportedOperationException:Thisisnotsupported,useMenuItemCompat.setOnActionExpandListener()atandroid.support.v7.internal.view.menu.MenuItemImpl.setOnActionExpandListener(MenuItemImpl.java:740)atbiz.nickbullcomputing.bevnav.MainActivity.onCrea

java - 为什么 MenuItemCompat.getActionProvider 返回 null?

我尝试在我的应用程序的操作栏上使用android.support.v7.widget.ShareActionProvider。所以我按照android文档中的示例进行操作,但遇到了一些问题。这是我的菜单xml:这是我创建分享操作按钮的代码:@OverridepublicvoidonCreateOptionsMenu(Menumenu,MenuInflaterinflater){inflater.inflate(R.menu.share,menu);MenuItemshareItem=menu.findItem(R.id.action_share);ShareActionProvider

java - 为什么 MenuItemCompat.getActionProvider 返回 null?

我尝试在我的应用程序的操作栏上使用android.support.v7.widget.ShareActionProvider。所以我按照android文档中的示例进行操作,但遇到了一些问题。这是我的菜单xml:这是我创建分享操作按钮的代码:@OverridepublicvoidonCreateOptionsMenu(Menumenu,MenuInflaterinflater){inflater.inflate(R.menu.share,menu);MenuItemshareItem=menu.findItem(R.id.action_share);ShareActionProvider

android - 无法设置 OnActionExpandListener : This is not supported, 使用 MenuItemCompat.setOnActionExpandListener()

这听起来像是一个重复的问题,但事实并非如此。我正在尝试设置OnActionExpandListener到我的搜索菜单项:publicbooleanonCreateOptionsMenu(Menumenu){MenuInflaterinflater=getMenuInflater();inflater.inflate(R.menu.menu_country_picker,menu);MenuItemmenuItem=menu.findItem(R.id.search);menuItem.setOnActionExpandListener(this);//morecodereturntru

android - MenuItemCompat.setOnActionExpandListener 已弃用

如果搜索View是否打开,我有一些代码可以设置一个bool值。MenuItemCompat.setOnActionExpandListener(action_search,newMenuItemCompat.OnActionExpandListener(){@OverridepublicbooleanonMenuItemActionExpand(MenuItemitem){isSearch=true;returntrue;}@OverridepublicbooleanonMenuItemActionCollapse(MenuItemitem){isSearch=false;return

android - MenuItemCompat.setOnActionExpandListener 什么都不做

背景我有一个正在使用我创建的特殊类初始化的searchView,它被用于所有Activity和fragment。问题最近可能是支持库更新的缘故(也可能是之前没用过,记不太清了),抓不到searchView展开/折叠的事件。正如我所发现的,即使我将setSupportActionBar与Toolbar实例一起使用,也会发生这种情况。我尝试过的我已经尝试使用下面的每一种方法,但都没有用:MenuItemCompat.setOnActionExpandListener。MenuItemCompat.setOnActionExpandListener以及图标化SearchView,如某些网站所
12