我正在使用visual studio中的Android壁纸应用程序并得到上面提到的这个错误。我包括了Gallery和来自xamarin网站的一些ImageAdapter代码,这里是链接https://developer.xamarin.com/guides/android/user_interface/gallery/。当我最终编译时,它说Gallary在我的mainactivity.cs文件中已经过时了。
namespace wallpaperApp
{
[Activity(Label = "wallpaperApp", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Gallery gallery = (Gallery)FindViewById<Gallery>(Resource.Id.gallery);
gallery.Adapter = new ImageAdapter(this);
gallery.ItemClick += delegate (object sender, Android.Widget.AdapterView.ItemClickEventArgs args) {
Toast.MakeText(this, args.Position.ToString(), ToastLength.Short).Show();
};
}
}
}
答案 0 :(得分:0)
Android中的Gallery小部件现已过时,应替换为其他内容。一些可能的解决方案可以在Xamarin论坛上找到:
在Xamarin.Android中处理多个图像/位图(实际上, 在Android中一般而言)非常棘手。我建议你继续使用 图像下载器第三方如Universal Image Loader, Glide,Picasso等。另外看一看 https://github.com/rdio/tangoandcache它适用于xamarin的GC 并利用位图重用。
https://forums.xamarin.com/discussion/45567/gallery-imageview-explodes-memory