【问题标题】:Uri images not showing on android device (Xamarin)Uri 图像未显示在 android 设备上 (Xamarin)
【发布时间】:2019-10-20 01:07:07
【问题描述】:

我正在尝试使用 ImageCell 显示图像,它在 UWP 上运行良好,但是当我使用我的 android 设备进行调试时它不会出现

一些解决方案建议将 HttpClient 实现更改为 Managed 并将 SSL/TLS 实现更改为 Native TLS 1.2+,我这样做了,但没有成功!

我还尝试按照一种解决方案的建议将大小减小到 10 * 10,但也没有用

另一个解决方案说问题与 byte[] 有关,它只是一个 android 问题,但我该如何改变呢??

所以我有一个班级联系人

public class Contact : ContentPage
    {
        public string Name { get; set; }

        public string Status { get; set; }

        public string ImageUrl { get; set; }
    }

这是后面的代码

public Demo ()
        {
            InitializeComponent ();

            listView.ItemsSource = new List<Contact>
            {
                new Contact {Name = "Khaled", ImageUrl="http://lorempixel.com/100/100/people/1"},
                new Contact {Name = "Mohammed", ImageUrl="http://lorempixel.com/100/100/people/2", Status = "Hey, lets talk"}
            };
        }

这是 xaml 代码

<ListView x:Name="listView">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ImageCell Text="{Binding Name}" Detail="{Binding Status}" ImageSource="{Binding ImageUrl}" />
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

【问题讨论】:

  • 您的 Android 应用是否具有 Internet 权限?您是否查看了应用程序输出日志以查看是否显示任何有关图像的消息?
  • @Jason 非常感谢!我在 androidManifest.xml 中添加了互联网权限,它现在可以工作了(Y)我很新,所以我什至没有想到它!再次感谢

标签: c# android xamarin cross-platform


【解决方案1】:

我修好了!我所要做的就是在 android 项目的属性中为 androidManifest.xml 添加互联网权限,如下所示:

<uses-permission android:name="android.permission.INTERNET" />

现在效果很好

【讨论】:

    猜你喜欢
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-27
    • 2014-08-22
    • 1970-01-01
    相关资源
    最近更新 更多