【发布时间】:2017-06-26 18:32:45
【问题描述】:
我不熟悉在 firebase 中执行查询。在我的代码下面,我使用快照将数据提取到我的列表视图中。我正在传递 List,但进一步阅读,我发现 List 无法转换为 Datasnaphot,答案需要使用 GenericTypeIndicator。我尝试使用它来将我的数据放入我的 listView 中,但这并不能解决问题。
为什么我会收到此错误Error: The non-generic type 'GenericTypeIndicator' cannot be used type arguments.?
活动
GenericTypeIndicator<List<GetUserContent>>messages = new GenericTypeIndicator<List<GetUserContent>>(){};
public void OnDataChange(DataSnapshot snapshot)
{
messages.Clear();
var items = snapshot.Child(post_key);
messages.Add((GetUserContent)items);
ViewAdapter adapter = new ViewAdapter(this, messages);
Console.WriteLine("Data being fetched " + items);
mylistview.Adapter = adapter;
}
适配器
internal class ViewAdapter: BaseAdapter
{
private List<GetUserContent> messages;
public ViewAdapter(Activity activity,List<GetUserContent> messages)
{
this.activity = activity;
this.messages = messages;
}
GetUserContent 类
internal class GetUserContent
{
public string Email { get; set; }
public string Message { get; set; }
public GetUserContent()
{
}
public GetUserContent(string Email, string Message){
this.Email = Email;
this.Message = Message;
}
}
发帖
mLike.Child(post_key).Child(mAuth.CurrentUser.Uid).Push().SetValue(edtChat.Text);
【问题讨论】:
-
发布
GenericTypeIndicator的定义 -
@dcg 我没有任何定义:)。我在这里进行了进一步的阅读stackoverflow.com/questions/30744224/…
-
@dcg,你的陈述思想是什么意思?
-
我以为是你的代码,我只是想看看它的定义来分析错误并给你(如果可能的话)我的帮助。
-
@dcg 我能够获取正在获取的项目,但我很难将其传递到我的列表视图
标签: c# android xamarin xamarin.android