我在andrdoid Xamarin中实现了Resources.GetDrawable
。该程序的工作原理,但如果我点击实施Resources.GetDrawable
程序的力量关闭。这里是我的代码:C# - Resources.GetDrawable已在Android Xamarin中废弃
SetContentView(Resource.Layout.Main);
drawView = FindViewById<DrawingView>(Resource.Id.drawing);
LinearLayout paintLayout = FindViewById<LinearLayout>(Resource.Id.paint_colors);
currPaint = (ImageButton)paintLayout.GetChildAt(0);
currPaint.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.paint_pressed));
的Resources.GetDrawable(Resource.Drawable.paint_pressed
了绿色(在Visual Studio 2015 Xamarin)强调。日志消息返回例外:
Android.Content.Res.Resources + NotFoundException
'Resources.GetDrawable(INT)' 已过时: '不赞成使用'
对于Java版的解决方案是利用这3个中的一个:
ResourcesCompat.getDrawable(getResources(), R.drawable.name, null);
//or
ContextCompat.getDrawable(getActivity(), R.drawable.name);
//or
ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme);
是什么版本的C#的Android Xamarin?谢谢。
看来工作,绿色下划线消失了。但该按钮仍然强制关闭应用程序。谢谢。 –