안녕하세요 저는 Xamarin 양식의 Android 응용 프로그램에서 서비스에서 json 데이터를 가져 오는 중입니다. ContactInfo 클래스에서 해당 데이터를 표시하도록되어 있습니다. 그 데이터를 가져 와서 표시 한 다음 ContactInfo 클래스로 이동합니다. 잠시 후 갤럭시 s7에서 앱이 응답하지 않는다고 알려 주면 닫으시겠습니까? 나는 내가Xamarin forms android json - 비동기 호출이 응답하지 않거나 응답하지 않습니다.
잘못 뭘하는지 몰라 여기 내 XAML의 :
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ReadyMo.ContactInfo">
<ListView ItemsSource="{Binding ContactInfoList}" HasUnevenRows="true">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame Padding="0,0,0,8" BackgroundColor="#d2d5d7">
<Frame.Content>
<Frame Padding="15,15,15,15" OutlineColor="Gray" BackgroundColor="White">
<Frame.Content>
<StackLayout Padding="20,0,0,0" Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Label x:Name="FirstName" Text="{Binding First_Name}" HorizontalOptions="Center">
</Label>
<Label x:Name ="LastName" Text="{Binding Last_Name}" HorizontalOptions="Center">
</Label>
<Label x:Name="County" Text="{Binding name}" HorizontalOptions="Center">
</Label>
<Label x:Name ="Adress" Text="{Binding Address1}" HorizontalOptions="Center">
</Label>
<Label x:Name ="City" Text="{Binding Address2}" HorizontalOptions="Center">
</Label>
<Label x:Name="Number" Text="{Binding BusinessPhone}" HorizontalOptions="Center">
</Label>
</StackLayout>
</Frame.Content>
</Frame>
</Frame.Content>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
여기 내 코드 숨김이있다 :
using Newtonsoft.Json;
using ReadyMo.Data;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace ReadyMo
{
public partial class ContactInfo : ContentPage
{
private County item;
public static async Task<string> GetContactString(string contactid)
{
HttpClient client = new HttpClient();
var url = $"http://sema.dps.mo.gov/county/service.php?id={contactid}";
var response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var responsetext = await response.Content.ReadAsStringAsync();
return responsetext;
}
throw new Exception(response.ReasonPhrase);
}
public ContactInfo()
{
InitializeComponent();
}
List <ContactInfoModel> ContactInfoList;
public ContactInfo(County item)
{
InitializeComponent();
this.item = item;
var contactpagetext = ContactManager.GetContactString(item.id);
var contact = GetContactString("001").Result;
//need to add update database code
//Convert Jason string to object
ContactInfoList = JsonConvert.DeserializeObject<List<ContactInfoModel>>(contact);
this.BindingContext = ContactInfoList;
//Floodplain Administrators
}
}
}
도움 놀라운 것은!
감사합니다.
교수형 문제를 해결 한 답장을 보내 주셔서 감사합니다.하지만 그렇지 않습니다. listview에 모든 내용을 표시 하시겠습니까? 그것의 다만 이것을하는 왜에 관한 어떤 생각든지 백색 페이지를 보여주기? 지금까지 모든 도움에 감사드립니다! :) – Phoneswapshop
물론, 나는 그 부분을 처리하기위한 답에 더 많은 것을 추가했다. –
OMG 그게 정말 고마워! !!!!!!! – Phoneswapshop