在Xamarin中,如何使用此链接中的MultiImageView
组件显示图像:http://components.xamarin.com/view/MultiImageView?
以下是我在网页上提供的代码:
base.OnCreate(bundle);
MultiImageView imageView = new MultiImageView (this);
imageView.LoadImageList(new [] {
"http://blog.xamarin.com/wp-content/uploads/2013/01/evolve-badge.png",
"http://oi50.tinypic.com/dfzo0k.jpg",
"http://oi49.tinypic.com/kd6fcp.jpg"});
imageView.ImagesLoaded += (sender, e) =>
{ // Loads the first image in the list
RunOnUiThread(imageView.LoadImage);
};
应用程序编译,但未显示任何图像。此外,没有错误。
我必须使用布局吗?
我可以帮助您使用此代码吗?
提前致谢
答案 0 :(得分:0)
您并未在任何地方将MultiImageView
添加到您的UI布局中。
尝试将其添加到现有布局(例如LinearLayout
)中以使其生效:
主要活动
// ...
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
var view = FindViewById<LinearLayout> (Resource.Id.viewContent);
MultiImageView imageView = new MultiImageView (this);
imageView.LoadImageList(new [] {
"http://blog.xamarin.com/wp-content/uploads/2013/01/evolve-badge.png",
"http://oi50.tinypic.com/dfzo0k.jpg",
"http://oi49.tinypic.com/kd6fcp.jpg"});
imageView.ImagesLoaded += (sender, e) =>
{ // Loads the first image in the list
RunOnUiThread(imageView.LoadImage);
};
view.AddView (imageView);
}
// ...
<强> Main.axml 强>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/viewContent">
</LinearLayout>