c# - Xamarin.Forms 显示列表中的数据在调试但不在 Release模式下工作

标签 c# xamarin xamarin.forms.listview

我有一个代码,它以 xamarin 形式将数据显示为列表。它在 Debug模式下显示良好,但在发布或 APK 时不显示任何列表。它 Release模式显示列表中的显示按钮,它只是一个静态的。 以下是我在表单中完成的代码。任何人都可以指导我解决这个问题。

<StackLayout>
    <ListView Grid.Row="1" x:Name="listLogin" ItemsSource="{Binding callLogList}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <ViewCell.View>
                        <Grid x:Name="Item">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Image Grid.Column="1" x:Name="ImgCallType" Source="{Binding ImageUrl}" Style="{Binding width:50px,height:50px;}"></Image>
                            <Label Grid.Column="2" FontSize="Subtitle" Text="{Binding Mobilenumber}"></Label>
                            <Label Grid.Column="3" FontSize="Subtitle" Text="12345"></Label>
                            <Button  Grid.Column="4"  Text="Add"  TextColor="Black"   HorizontalOptions="EndAndExpand" Clicked="" CommandParameter="{Binding Mobilenumber}"/>
                        </Grid>
                    </ViewCell.View>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</StackLayout>

public partial class MiscallData : ContentPage
    {
        public MiscallData()
        {
            InitializeComponent();
            GetCallLogs();
        }
        public void GetCallLogs()
        {
            Android.Content.Context myContext = Android.App.Application.Context;

            string OutgoingqueryFilter = string.Format("{0}={1}", CallLog.Calls.Type, (int)CallType.Outgoing);
            string querySorter = string.Format("{0} desc ", CallLog.Calls.Date);

            ICursor OutgoingqueryData = myContext.ContentResolver.Query(CallLog.Calls.ContentUri, null, null, null, querySorter);
            List<MisscallDataModel> callLogList = new List<MisscallDataModel>();

            while (OutgoingqueryData.MoveToNext())
            {
                MisscallDataModel model = new MisscallDataModel();

                //---phone number---
                model.Mobilenumber = OutgoingqueryData.GetString(OutgoingqueryData.GetColumnIndex(CallLog.Calls.Number));

                //---date of call---
                int secondindex = OutgoingqueryData.GetColumnIndex(CallLog.Calls.Date);
                long seconds = OutgoingqueryData.GetLong(secondindex);
                SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy HH:mm");
                String dateString = formatter.Format(new Date(seconds));
                model.Date = dateString;
                model.ImageUrl = "BlockCall.png";
                callLogList.Add(model);
            }
            listLogin.ItemsSource = callLogList;
        }
    }

public class MisscallDataModel
    {
        public long UserId { get; set; }
        public string Mobilenumber { get; set; }
        public string Date { get; set; }
        public string callType { get; set; }
        public string ImageUrl { get; set; }

    }

最佳答案

我自己解决了我的问题,代码没有问题,只是在属性设置中设置了, 只需转到 android 属性然后选择 android 选项,只需找到链接器属性有链接,选择选项无,就是这样。

Android 项目 => 属性 => Android 选项 => 链接器属性 => 链接 => 无。

关于c# - Xamarin.Forms 显示列表中的数据在调试但不在 Release模式下工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57182100/

相关文章:

c# - 当方向改变时,如何防止 Xamarin Forms ScrollView 中的内容卡住?

c# - 从 ViewModel 调用 View Code Behind 中的方法?

c# - Xamarin App 仅在 Debug模式下崩溃

c# - 我无法访问 x :Name of controls in ListView in XAML and Code behind

c# - 如何在XP或7中使用C#连接默认拨号?

c# - moq 模拟 buffer[] 参数

c# - 如何找到数字列表中的总冗余

android - TabbedPage 中 ListView 中的 Xamarin Forms Slider 无法正确滑动

listview - 选择项目时,xamarin Forms ListView Item Taped 和 ItemSelected 一起运行

c# - C# 泛型命名约定从何而来?