2016-07-08 28 views
0

我堅持在Udacity Firebase課程中實現FireBase UI ListAdapter。整個東西已經改變了很多,現在ActiveListAdapter.java拋出錯誤:Udacity Firebase教程 - 實現Firebase UI列表適配器

Cannot resolve method 'super(andoid.app.Activity, java.lang.Class, int, com.google.firebase.database.Query)'

有沒有人遇到過這個問題?你知道如何解決它嗎?

這是我ActiveListAdapter.java

import android.app.Activity; 
import android.view.View; 
import android.widget.TextView; 

import com.firebase.ui.FirebaseListAdapter; 
import com.google.firebase.FirebaseApp; 
import com.google.firebase.database.FirebaseDatabase; 
import com.google.firebase.database.Query; 
import com.udacity.firebase.shoppinglistplusplus.R; 
import com.udacity.firebase.shoppinglistplusplus.model.ShoppingList; 

/** 
* Populates the list_view_active_lists inside ShoppingListsFragment 
*/ 
public class ActiveListAdapter extends FirebaseListAdapter<ShoppingList> { 

    /** 
    * Public constructor that initializes private instance variables when adapter is created 
    */ 
    public ActiveListAdapter(Activity activity, Class<ShoppingList> modelClass, int modelLayout, 
          Query ref) { 
     super(activity, modelClass, modelLayout, ref); 
     this.mActivity = activity; 
    } 

    /** 
    * Protected method that populates the view attached to the adapter (list_view_active_lists) 
    * with items inflated from single_active_list.xml 
    * populateView also handles data changes and updates the listView accordingly 
    */ 

    @Override 
    protected void populateView(View view, ShoppingList list, int i) { 
     /** 
     * Grab the needed Textivews and strings 
     */ 
     TextView textViewListName = (TextView) view.findViewById(R.id.text_view_list_name); 
     TextView textViewCreatedByUser = (TextView) view.findViewById(R.id.text_view_created_by_user); 


     /* Set the list name and owner */ 
     textViewListName.setText(list.getListName()); 
     textViewCreatedByUser.setText(list.getOwner()); 
    } 
} 
+0

你能發佈完整的錯誤日誌嗎? –

+0

它是:無法解析方法'超級(andoid.app.Activity,java.lang.Class ,int,com.google.firebase.database.Query)' –

+0

可以你展示瞭如何在你的build.gradle中包含FirebaseUI? –

回答

0

@Egor是正確的。您的構造函數應該如下所示:

public ActiveListAdapter(Activity activity, Class<ShoppingList> modelClass, int modelLayout, 
         Query ref) { 
    super(ref, modelClass, modelLayout, activity); 
    this.mActivity = activity; 
} 
0

我遇到了同樣的問題,但現在只做了很少的更改。編譯'com.firebaseui:firebase-ui:0.4.2' 和 2)編譯'com.google.firebase:firebase-auth:9.2.0' (您需要在build.gradle中將其他firebase版本更改爲9.2.0) 將導入命令更改爲 import com.firebase.ui.database.FirebaseListAdapter; 此前它是 import com.firebase.ui.FirebaseListAdapter;

2

這可能是因爲您正在使用最新的Firebase UI庫而已更新爲與Firebase庫9.2.1一起使用,而您的客戶端庫仍舊舊。

「com.firebaseui:火力的UI:0.4.3」

你必須使用最新的客戶端庫,並相應地更新你的查詢。

請參考以下鏈接: https://firebase.google.com/support/guides/firebase-android

在ShoppingListsFragment,我的疑問是基於老火力客戶端庫並創建了一個類似的問題。更新完畢後,所有事情都開始奏效!

'com.firebase:firebase-client-android:2.5.2'