简体   繁体   中英

Xamarin Firebase Database Connection to Listview

How can I connect my firebase database to my xamarin listview and get the value of it?

private List<string> mItems;
private ListView list_device;
private const string FirebaseURL = "https://abtrackslogin.firebaseio.com/";
FirebaseAuth auth;
DatabaseReference mDatabase;
protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);
    SetContentView(Resource.Layout.DeviceList);
    auth = FirebaseAuth.GetInstance(MainActivity.app);
    list_device = FindViewById<ListView>(Resource.Id.list_device);
    mDatabase = FirebaseDatabase.GetInstance(FirebaseURL).GetReference(auth.CurrentUser.Uid);
    GetData();
    list_device.ItemClick += listitemClick;
}
private void GetData()
{
    FirebaseDatabase
        .Instance
        .Reference
        .Child(auth.CurrentUser.Uid);
    ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mItems);
    list_device.Adapter = adapter;
}

在您的 URL 链接中尝试https://abtrackslogin.firebaseio.com/.json/这对我有用!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM