You cannot start a load on a not yet attached View or a Fragment where getActivity() returns null

前端 未结 5 1187
别跟我提以往
别跟我提以往 2021-01-13 21:26

I am using FragmentStatePagerAdapter to show around 5 fragments in an activity.On each activity I am showing the images which I am fetching from FirebaseListAdapter/Firebase

5条回答
  •  借酒劲吻你
    2021-01-13 21:47

    ArrayList clientData = new ArrayList<>();
    int j=0;
    for (String h:profileImg)
    {
        ClientData clientItem = new ClientData();
        clientItem.setProfileImage(h);
        clientItem.setName(name[j]);
        clientItem.setAddress(location[j]);
        clientData.add(clientItem);
        j++;
        }
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplication(),RecyclerView.VERTICAL,false);
        recy_client.setLayoutManager(layoutManager);
        recy_client.setItemAnimator(new DefaultItemAnimator());
        clientAdp = new ClientAdp(getApplicationContext(),clientData);
        recy_client.setAdapter(clientAdp);
    

    Replace From

    clientAdp = new ClientAdp(context,clientData);
    

    To

    clientAdp = new ClientAdp(getApplicationContext(),clientData);
    

    in my case

提交回复
热议问题