为tableviewdatasource添加列表而不是替换列表
本文关键字:列表 替换 添加 tableviewdatasource | 更新日期: 2023-09-27 18:09:08
我目前正在尝试添加分页到我的Instagram应用程序,并已设法取代列表,提供数据源与新数据,但我想将其添加到现有的列表,以便当我滚动回去它会显示最新的图片。以下是我目前的做法:
var request = new RestRequest { RootElement = "data", Resource = "/users/self/feed" };
request.AddParameter ("access_token", instagramAccessToken);
var client = new RestClient ("https://api.instagram.com/v1");
client.ExecuteAsync (request, response => {
var rootObject = JsonConvert.DeserializeObject<RootObject> (response.Content);
string nextURL = rootObject.pagination.next_url;
//// Create Next Client
var requestBack = new RestRequest ();
var clientBack = new RestClient (nextURL);
// GET Next Response
clientBack.ExecuteAsync(requestBack, responseBack => {
var rootObjectBack = JsonConvert.DeserializeObject<RootObject> (responseBack.Content);
table.InvokeOnMainThread (() => {
// Create list that contains newly attained JSON
List<Datum> instagramData = rootObjectBack.data;
// Create dummy list for other values
List<Datum> sloppy = null;
// Send list that contains data, and the sloppy which doesnt contain anything to the Facebook and Twitter Values.
table.Source = new TableSource<Datum>(instagramData, sloppy, sloppy);
table.ReloadData ();
});
});
});
List<x> A = initial data
List<x> B = new data
A.AddRange(B);
A现在把B附加到末尾
访问现有源
中的公共列表(假设它被称为"Data")((TableSource<Datum>)table.Source).Data