java.lang.UnsupportedOperationException: This is not supported, use MenuItemCompat.setOnActionExpandListener()

后端 未结 2 2081
甜味超标
甜味超标 2021-01-01 12:37

I have recently migrated from Eclipse to Android Studio and in doing so I have picked up the below error

java.lang.UnsupportedOperationException: This is not         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 12:57

    The fix thanks to ρяσѕρєя K's comment. Much appreciated mate, thank you!!

    MenuItemCompat.setOnActionExpandListener(searchItem,
                new MenuItemCompat.OnActionExpandListener() {
                    @Override
                    public boolean onMenuItemActionExpand(MenuItem menuItem) {
                        // Return true to allow the action view to expand
                        townList.setVisibility(View.VISIBLE);
                        return true;
                    }
                    @Override
                    public boolean onMenuItemActionCollapse(MenuItem menuItem) {
                        // When the action view is collapsed, reset the query
                        townList.setVisibility(View.INVISIBLE);
                        // Return true to allow the action view to collapse
                        return true;
                    }
                });
    

提交回复
热议问题