0

我坚持在 Udacity Firebase 课程中实施 FireBase UI ListAdapter。整个事情发生了很大变化,现在 ActiveListAdapter.java 抛出错误:

无法解析方法“超级(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());
    }
}
4

3 回答 3

2

这可能是因为您使用的是最新的 firebase UI 库,该库已更新为可与 firebase 库 9.2.1 一起使用,而您的客户端库仍然很旧。

'com.firebaseui:firebase-ui:0.4.3'

您必须使用最新的客户端库并相应地更新您的查询。

参考以下链接: https ://firebase.google.com/support/guides/firebase-android

在 ShoppingListsFragment 中,我的查询基于旧的 firebase 客户端库并产生了类似的问题。更新它们后,一切都开始工作了!

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

于 2016-07-22T12:09:09.117 回答
0

我有同样的问题,但现在通过做一些改变解决了。在 build.gradle 文件中,我更改了版本 1)编译 '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;

于 2016-07-19T16:48:18.783 回答
0

@Egor 是对的。您的构造函数应如下所示:

public ActiveListAdapter(Activity activity, Class<ShoppingList> modelClass, int modelLayout,
                         Query ref) {
    super(ref, modelClass, modelLayout, activity);
    this.mActivity = activity;
}
于 2016-07-08T12:57:51.280 回答