[英]Xamarin.Forms display a data in list works in debug but not in release mode
我有一個代碼,以xamarin形式將數據顯示為列表。 它在調試模式下顯示良好,但在發布或APK中則不顯示任何列表。 釋放列表中的模式顯示按鈕,僅是靜態的。 下面是我在表單中完成的代碼。 有誰能指導我解決這個問題。
<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選項,只需找到Linker屬性,其中存在linking,選擇選項None即可。
Android項目=>屬性=> Android選項=>鏈接器屬性=>鏈接=>無。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.