无法转换类型为java.lang.Boolean的对象

时间:2019-03-31 13:28:34

标签: java android firebase firebase-realtime-database

在这个主题中我已经看了很多主题,但是我无法在自己的代码中修改代码。因为显然有一个我看不到的错误。而且我得到了错误。

EpisodeModel.class

公共类EpisodeModel {

>>> dates
array([19700101., 19700102., 19700103., 19700104., 19700105., 19700106.,
       19700107., 19700108., 19700109., 19700110., 19700111., 19700112.,
       19700113., 19700114.])
>>> y, m, d = dates.astype(int) // np.c_[[10000, 100, 1]] % np.c_[[10000, 100, 100]]
>>> y.astype('U4').astype('M8') + (m-1).astype('m8[M]') + (d-1).astype('m8[D]')
array(['1970-01-01', '1970-01-02', '1970-01-03', '1970-01-04',
       '1970-01-05', '1970-01-06', '1970-01-07', '1970-01-08',
       '1970-01-09', '1970-01-10', '1970-01-11', '1970-01-12',
       '1970-01-13', '1970-01-14'], dtype='datetime64[D]')

}

MyFragment.class

private String episode;

public EpisodeModel(String episode) {
    this.episode = episode;
}

public EpisodeModel()
{

}

public String getEpisode() {
    return episode;
}

public void setEpisode(String episode) {
    this.episode = episode;
}

@Override
public String toString() {
    return "EpisodeModel{" +
            "episode='" + episode + '\'' +
            '}';
}

Logcat

public void check() {
        ref.child("Users").child(user.getUid()).child("Watched").child(seriesTitle).child("Season").child(seasonGet)
                .addChildEventListener(new ChildEventListener() {
                    @Override
                    public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

                        EpisodeModel episodeModel = dataSnapshot.getValue(EpisodeModel.class);
                        Log.i("child",episodeModel.toString());

                        Log.i("test","test2");
                        String st = dataSnapshot.getKey();
                        int no = Integer.parseInt(st);

                        if(!deneme.contains(no))
                        {
                            deneme.add(no);
                        }

                        checkModelTestAdapter.notifyDataSetChanged();
                    }


...onChildChanged..onChildRemoved..onChildMoved..onCancelled..}};

1 个答案:

答案 0 :(得分:0)

  

EpisodeModel EpisodeModel = dataSnapshot.getValue(EpisodeModel.class);

在此行中,您得到错误消息,表明布尔对象无法转换为EpisodeModel。如果您已将该子项的值设置为 true false 不带双引号),则可能会出现此消息。再次看到它,并尝试在要设置为子值的“ true” “ false” 周围添加双引号。