我坚持在Udacity Firebase课程中实现FireBase UI ListAdapter。整个过程发生了很大的变化,现在ActiveListAdapter.java引发了错误:
无法解析方法'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 :(得分: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:火力-客户机器人:2.5.2'
答案 1 :(得分:0)
public ActiveListAdapter(Activity activity, Class<ShoppingList> modelClass, int modelLayout,
Query ref) {
super(ref, modelClass, modelLayout, activity);
this.mActivity = activity;
}
答案 2 :(得分: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;