无法解析Firebase列表适配器中的构造函数

时间:2017-03-22 20:39:51

标签: android listview firebase firebase-realtime-database firebaseui

这是我的代码,我无法弄清楚导致它无法解决构造函数错误的原因。任何帮助将不胜感激。

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import com.firebase.ui.FirebaseListAdapter;
import com.google.firebase.database.FirebaseDatabase;
public class Home extends AppCompatActivity {

private FirebaseDatabase mFirebaseRef;
FirebaseListAdapter<ChatMessage> mListAdapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    final ListView listView = (ListView) this.findViewById(android.R.id.list);

我的错误从这里开始(这,

    mListAdapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class,
            android.R.layout.two_line_list_item, mFirebaseRef) {
        @Override
        protected void populateView(View v, ChatMessage model, int position) {
            ((TextView)v.findViewById(android.R.id.text1)).setText(model.getName());
            ((TextView)v.findViewById(android.R.id.text2)).setText(model.getText());
        }
    };
    listView.setAdapter(mListAdapter);



    };
}

依赖关系:

 compile 'com.android.support:appcompat-v7:25.3.0'
 compile 'com.android.support.constraint:constraint-layout:1.0.1'
 compile 'com.google.firebase:firebase-auth:10.0.1'
 compile 'com.google.firebase:firebase-core:10.2.0'
 compile 'com.google.firebase:firebase-auth:10.2.0'
 compile 'com.google.firebase:firebase-database:10.2.0'
 compile 'com.google.firebase:firebase-messaging:10.2.0'
 compile 'com.google.firebase:firebase-crash:10.2.0'
 compile 'com.android.support:recyclerview-v7:25.3.0'
 compile 'com.firebaseui:firebase-ui:0.3.1'

1 个答案:

答案 0 :(得分:1)

您应该导入:

com.firebase.ui.database.FirebaseListAdapter

而不是:

com.firebase.ui.FirebaseListAdapter

还要对build.gradle依赖项进行这些更改:

compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.firebaseui:firebase-ui:1.2.0'

Firebase UI兼容版本表位于the documentation