这是我从 API 获取值的示例代码:
我的班级信息(模型)
public class COUNTRESULT_Info
{
public decimal STDSKU { get; set; }
public decimal STDQTC { get; set; }
public string CSTSDS { get; set; }
public string STDDSC { get; set; }
}
我的 API 存储库:
public async Task<List<T>> GetCountResult(string trfnumber, string usertype) {
var httpClient = new HttpClient();
var json = await httpClient.GetStringAsync("http://hoscbdd1:8888/api/result/GETCOUNTRESULT/"+trfnumber+"/"+usertype);
return JsonConvert.DeserializeObject<List<T>>(json);
}
}
Android 活动(通过列表视图):
private async void GetCountResult(string trfnumber, string usertype) {
ResultRepository<COUNTRESULT_Info> repo = new ResultRepository<COUNTRESULT_Info>();
var result = await repo.GetCountResult(trfnumber, usertype);
if (result != null)
{
stringResult = result.Select(x => x.ToString()).ToList();
adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, stringResult);
listview_countresult.Adapter = adapter;
}
}
我的列表视图中的输出是计算找到的对象数量,例如:
SCRS.MODEL.COUNTRESULT_Info
SCRS.MODEL.COUNTRESULT_Info
SCRS.MODEL.COUNTRESULT_Info
SCRS.MODEL.COUNTRESULT_Info
SCRS.MODEL.COUNTRESULT_Info
手掌心
梵蒂冈之花
相关分类