设置工具栏图标以响应点击

问题描述

经过大量研究,我发现了这段代码,我可以用它在工具栏中填充图标。 我的工具栏上有两个图标,一个是三个点状图标,另一个是搜索图标,IDE已经生成了一个图标的功能,并且工作正常,还没有弄清楚如何对搜索图标进行编程,以请求EditText的键盘焦点在同一工具栏中... 我的代码在下面

//Code to populate the toolbar with icons 
  public override bool OnCreateOptionsMenu(IMenu menu)
        {
   //This one inflates a three dotted menu to the rightmost part of the toolbar
            MenuInflater.Inflate(Resource.Menu.menu2,menu);
//This one adds a search icon next to the Three dotted menu
            MenuInflater.Inflate(Resource.Menu.menu4,menu);
       
            return true;
        }
//This method handles the functionality of the three dot menu icon by generating the associated menu
  public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;
            if (id == Resource.Id.action_settings)
            {
                Intent intent = new Intent(this,typeof(SecondActivity));

                StartActivity(intent);
                OverridePendingTransition(Resource.Animation.slide_in_right,Resource.Animation.abc_popup_exit);
                return true;
            }

            return base.OnOptionsItemSelected(item);
        }
//I need code here to make the search icon do something,some kind of inbuilt method or something thanks

如何使用内置方法或任何其他方式对添加到工具栏的其他图标进行编程肯定会受到感谢...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)