私のデータベースのアイテムキーを取得したいのですが、DataSnapshot関数で見られるようにアイテムキーを取得しようとしましたが空に戻ります。すべてのアイテムキーをデータフェッチにバインドしようとしています。だから私はキーを使用することができますので、フェッチされたすべての項目は、そのキーを持っている必要があります。しかし、アイテムキーを除いて他のすべての要素がフェッチされます。アイテムキーが表示されないのはなぜですか?あなたの助けFirebugからアイテムキーを取得する方法
構造
モデルをありがとう
public Hero(string uid,string name, string achievment, string history, string quote)
{
this.uid = uid;
this.name = name;
this.achvievment = achievment;
this.history = history;
this.quote = quote;
}
public HashMap ToMap()
{
HashMap map = new HashMap();
map.Put("Uid", this.uid);
map.Put("Name", this.name);
map.Put("Achievement", this.achvievment);
map.Put("History", this.history);
map.Put("Quote", this.quote);
return map;
}
public string Uid
{
get { return uid; }
set { uid = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public int Image
{
get { return image; }
set { image = value; }
}
public string Achievement
{
get { return achvievment; }
set { achvievment = value; }
}
public string History
{
get { return history; }
set { history = value; }
}
public string Quote
{
get { return quote; }
set { quote = value; }
}
セーブデータ
//this is how i save my data which works fine
mHero.Push().SetValue(new PeaceHero(user.Uid,HeroName.Text, HeroAchv.Text, HeroHistory.Text, HeroQuote.Text).ToMap());
データのフェッチ
public void OnDataChange(DataSnapshot snapshot)
{
var items = snapshot.Children?.ToEnumerable<DataSnapshot>();
HashMap map;
foreach (DataSnapshot item in items)
{
map = (HashMap)item.Value;
Hero.Add(new Hero(map.Get(item.Key)?.ToString(),map.Get("Name")?.ToString(), map.Get("Achievement")?.ToString(),map.Get("History")?.ToString(),map.Get("Quote")?.ToString()));
Console.WriteLine("Sending item key" +item.Key.ToString());
key = item.Key;
}
HeroAdapter adapter = new PeaceHeroAdapter(Hero,this);
Console.Write("The key is "+key);
}
何が問題でしたか? 'Key.ToString()'を呼び出す必要があるのはなぜでしょうか? 'Console.WriteLine("アイテムキー "+ item.Key.ToString());" –
アイテムをバインドしようとしましたが、 foreachループ内のすべてのデータ呼び出しのキー – Switz