2016-07-23 51 views
-2

这是我FirebaseDatabaseListView的形式FirebaseDatabase

{ 
    "tips" : { 
    "tip1" : "dfh", 
    "tip2" : "dfgh", 
    "tip3" : "dfghd", 
    "tip4" : "dfh" 
    } 
} 

我想通过提示的值来填充ListView控件在我的Android aplication(DFG,dfgh ...) 如何才达到的呢?我在Google Developers上发现了有关Firebase用户界面的电影,但有新版本的Firebase,它不能像这样工作。

+0

所以你还没有试过或研究过任何东西,并来到这里要求代码。 – muratgu

+0

这对你来说很难吗? – krzystooof

+0

帮助自己并先阅读文档:https://firebase.google.com/docs/database/android/start/ – muratgu

回答

0

不,我试图下载数据,然后进行列表视图,但它崩溃了。我在这里不是为现成的代码,而是为了提示。我找不到任何教程或说明。如果你已经把链接放在这里,我会很高兴。 编辑 对不起张贴的答案,但意见并没有在移动工作,我不能删除它现在

+0

您可以从这里开始:https://firebase.google.com/docs/database/android/start / – muratgu

0

当设备节点 的名称和delayTime是它限制了前70个记录的整场

final ListView list = (ListView) findViewById(R.id.list); 


    Query deviceListQuery = mDatabase.child("device") 
      .orderByChild("delayTime").limitToFirst(70); 

    deviceListQuery.addListenerForSingleValueEvent(
      new ValueEventListener() { 
       @Override 
       public void onDataChange(DataSnapshot dataSnapshot) { 
        // Get user value 

        if (progress != null) { 
         progress.dismiss(); 

        } 

        mLoadingText.setVisibility(View.GONE); 

        for (DataSnapshot child : dataSnapshot.getChildren()) { 
         Device device = child.getValue(Device.class); 
         Log.d("xxx-xxxx", "=" + device.delayTime); 
         mDeviceList.add(device); 
        } 


        if (mDeviceList.size() > 0) { 
         DeviceListAdapter deviceListAdapter = new DeviceListAdapter(getApplicationContext(), mDeviceList); 
         list.setAdapter(deviceListAdapter); 
        } 
        // ... 
       } 

       @Override 
       public void onCancelled(DatabaseError databaseError) { 
        Log.w("xxxxxerror", "getUser:onCancelled", databaseError.toException()); 
        mLoadingText.setText("Error. Please try again later"); 
       } 
      });