我一直试图在可通过nuget获得的circlemenu库中实现接口:
https://github.com/Hitomis/CircleMenu
在我的xamarin android项目中,我无法调用和实现圆形菜单方法 .SetOnMenuStatusChangeListener(....)和.SetOnMenuStatusChangeListener(....)
中的接口这是我的xamarin c#代码
public class mainMenuActivity : Activity,IOnMenuStatusChangeListener,IOnMenuSelectedListener
{
CircleMenu circleMenu = null;
public void OnMenuClosed()
{
throw new NotImplementedException();
}
public void OnMenuOpened()
{
throw new NotImplementedException();
}
public void OnMenuSelected(int p0)
{
Toast.MakeText(this, "selected " + p0, ToastLength.Long).Show();
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.mainmenu);
var circleMenu = FindViewById<CircleMenu>(Resource.Id.circle_menu);
circleMenu.SetMainMenu(Color.ParseColor("#98ccfd"), Resource.Mipmap.menu, Resource.Mipmap.cancel)
.AddSubMenu(Color.ParseColor("#258CFF"), Resource.Mipmap.scanner)
.AddSubMenu(Color.ParseColor("#30A400"), Resource.Mipmap.mapmarker)
.AddSubMenu(Color.ParseColor("#fe9b93"), Resource.Mipmap.support)
.AddSubMenu(Color.ParseColor("#25b7d3"), Resource.Mipmap.share)
.AddSubMenu(Color.ParseColor("#f44336"), Resource.Mipmap.shutdown);
//.SetOnMenuStatusChangeListener();
this.circleMenu = circleMenu;
}
}
显然,在类级别实现该接口不会将其与circlemenu绑定在一起。
这是假定代码的Java版本
circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.mipmap.icon_menu,
R.mipmap.icon_cancel)
.addSubMenu(Color.parseColor("#258CFF"), R.mipmap.icon_home)
.addSubMenu(Color.parseColor("#30A400"), R.mipmap.icon_search)
.addSubMenu(Color.parseColor("#FF4B32"), R.mipmap.icon_notify)
.addSubMenu(Color.parseColor("#8A39FF"), R.mipmap.icon_setting)
.addSubMenu(Color.parseColor("#FF6A00"), R.mipmap.icon_gps)
.setOnMenuSelectedListener(new OnMenuSelectedListener() {
@Override
public void onMenuSelected(int index) {}
}).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {
@Override
public void onMenuOpened() {}
@Override
public void onMenuClosed() {}
});