Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android Studio中设置FirebaseAdapter?_Android_Firebase_Firebaseui - Fatal编程技术网

如何在Android Studio中设置FirebaseAdapter?

如何在Android Studio中设置FirebaseAdapter?,android,firebase,firebaseui,Android,Firebase,Firebaseui,我正在尝试将数据从Firebase实时读取到自定义阵列适配器中。根据我的研究,FirebaseListAdapter似乎内置了处理此问题的功能。但是,我无法让代码识别FirebaseListAdapter类。如何使FirebaseListAdapter工作 梯度锉 FirebaseAdapter初始化 带列表的片段 自定义适配器 添加值的位置 也许您可以将Firebase依赖项更改为最新版本 compile 'com.google.firebase:firebase-database:9.6.0

我正在尝试将数据从Firebase实时读取到自定义阵列适配器中。根据我的研究,FirebaseListAdapter似乎内置了处理此问题的功能。但是,我无法让代码识别FirebaseListAdapter类。如何使FirebaseListAdapter工作

梯度锉 FirebaseAdapter初始化 带列表的片段 自定义适配器 添加值的位置
也许您可以将Firebase依赖项更改为最新版本

compile 'com.google.firebase:firebase-database:9.6.0'
compile 'com.google.firebase:firebase-core:9.6.0'
compile 'com.google.firebase:firebase-auth:9.6.0'

也许您可以将Firebase依赖项更改为最新版本

compile 'com.google.firebase:firebase-database:9.6.0'
compile 'com.google.firebase:firebase-core:9.6.0'
compile 'com.google.firebase:firebase-auth:9.6.0'
这本书很方便:

因此,为了使用FirebaseUI 0.6,您必须使用Firebase/Play Services SDK 9.6。如果要使用Firebase/Play Services SDK 9.4,则必须使用FirebaseUI 0.5

此外,还缺少列表适配器的导入语句:

import com.firebase.ui.database.FirebaseListAdapter;
Android Studio应该已经为您提供了有关此导入的提示。

具有以下功能:

因此,为了使用FirebaseUI 0.6,您必须使用Firebase/Play Services SDK 9.6。如果要使用Firebase/Play Services SDK 9.4,则必须使用FirebaseUI 0.5

此外,还缺少列表适配器的导入语句:

import com.firebase.ui.database.FirebaseListAdapter;

Android Studio应该已经为您提供了有关此导入的提示。

您是否安装了最新版本的Google Play Services?此外,本教程可能会帮助您@NollyJ是的,我昨天刚获取了最新版本。您是否安装了最新版本的Google Play Services?另外,本教程可能会帮助您@NollyJ是的,我昨天刚获取了最新版本。这解决了依赖项的问题,但我仍然存在FragmentListAdapter错误以及一个错误,该错误表示找不到support-v4.jarcom.android.support:support-v4:24.1.1该错误消息取决于实际的Java代码。由于您没有共享复制错误所需的最低代码,因此很难提供帮助。我在描述中添加了更多代码-您还需要查看其他内容吗?我添加了导入语句,导入给我错误:无法解决符号FirebaseListAdapter这解决了依赖项的问题,但是我仍然有FragmentListAdapter错误,还有一个错误说找不到support-v4.jarcom.android.support:support-v4:24.1.1该错误消息取决于实际的Java代码。由于您没有共享复制错误所需的最低代码,因此很难提供帮助。我在描述中添加了更多代码-您还需要查看其他内容吗?我添加了导入语句,导入给我错误:无法解析符号FirebaseListAdapter
import android.app.Activity;
import android.media.Image;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by Tim on 9/10/2016.
 */
public class ParticipantAdapter extends ArrayAdapter {
    public ParticipantAdapter(Activity context, ArrayList<Participant> participant) {
        super(context, 0, participant);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View listItemView = convertView;
        if(listItemView == null){
            listItemView = LayoutInflater.from(getContext()).inflate(R.layout.participants_list_item, parent, false);
        }

        Participant currentParticipant = (Participant) getItem(position);

        ImageView participantImage = (ImageView) listItemView.findViewById(R.id.participant_image);
        if(currentParticipant.hasImageValue()){
            participantImage.setImageResource(currentParticipant.getImageID());
        }else{
            participantImage.setImageResource(R.drawable.ic_my_profile);
        }

        TextView name = (TextView) listItemView.findViewById(R.id.participant_name);
        name.setText(currentParticipant.getDisplayName());

        ImageView image = (ImageView) listItemView.findViewById(R.id.participant_role);
        switch (currentParticipant.getRole()){
            case "Official": image.setImageResource(R.drawable.ic_official);
            case "Spectator": image.setImageResource(R.drawable.ic_spectator);
            case "Quizzer": image.setImageResource(R.mipmap.ic_quizzer);
            default: image.setVisibility(View.GONE);
        }

        return listItemView;
    }
}
Button okBtn = (Button) findViewById(R.id.add_participant);
        okBtn.setOnClickListener(new View.OnClickListener() {
            @Override

            public void onClick(View view) {
                DatabaseReference ref = database.child("participants");
                EditText firstName = (EditText)  findViewById(R.id.first_name);
                EditText lastName = (EditText)  findViewById(R.id.last_name);
                Participant newParticipant = new Participant(firstName.getText().toString(),
                                                                lastName.getText().toString(),
                                                                sp.getSelectedItem().toString(),
                                                                sp2.getSelectedItem().toString());
                Map<String, Object> participantValues = newParticipant.toMap();
                ref.push().setValue(participantValues);
            }
        });
compile 'com.google.firebase:firebase-database:9.6.0'
compile 'com.google.firebase:firebase-core:9.6.0'
compile 'com.google.firebase:firebase-auth:9.6.0'
FirebaseUI  Firebase/Play 
 Version    Services Version
   1.2.0       10.2.0
   1.1.1       10.0.0 or 10.0.1
   1.0.1       10.0.0 or 10.0.1
   1.0.0       9.8.0
   0.6.2       9.8.0
   0.6.1       9.6.1
   0.6.0       9.6.0
   0.5.3       9.4.0
   0.4.4       9.4.0
   0.4.3       9.2.1
   0.4.2       9.2.0
   0.4.1       9.0.2
   0.4.0       9.0.0
import com.firebase.ui.database.FirebaseListAdapter;