2016-07-23 39 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"); 
       } 
      }); 
相關問題