我在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?謝謝。
看來工作,綠色下劃線消失了。但該按鈕仍然強制關閉應用程序。謝謝。 –