FirebaseUI'无法解析FirebaseListAdapter构造函数'

时间:2016-12-04 11:19:27

标签: android firebase firebaseui

我正在尝试使用FirebaseListAdapter创建所有键的简单ListView,但我在构造函数方面遇到了一些困难。

这是我的代码:

build.gradle文件firebase依赖项

compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebaseui:firebase-ui:0.4.3'
包含列表视图的

片段

// Only showing firebase imports
import com.firebase.ui.database.FirebaseListAdapter;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

public class UpcomingBookings extends Fragment {
    private String title;
    private ListView bookingsList;
    private ArrayList<String> bookings;

    DatabaseReference mDatabase;
    DatabaseReference userBookingsDatabase;

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        mDatabase = FirebaseDatabase.getInstance().getReference().child("Users");
        userBookingsDatabase = mDatabase.child(userID).child("Bookings");

        // The problematic ListAdapter constructor
        ListAdapter firebaseListAdapter = new FirebaseListAdapter<String>(getContext(),String.class, android.R.layout.simple_list_item_1,userBookingsDatabase) {
            @Override
            protected void populateView(View view, String s, int i) {

            }
        };

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        View view = inflater.inflate(R.layout.fragment_upcoming_bookings,container,false);
        return view;
    }
}

目前,我收到错误Cannot resolve constructor,我已经尝试了其他相关stackoverflow问题中建议的方法(例如使用最新版本的firebase,更改import语句)。我该怎么办?

1 个答案:

答案 0 :(得分:2)

将其添加到您的项目gradl

compile 'com.firebaseui:firebase-ui:2.3.0'