Cannot resolve constructor ArrayAdapter(android.Content.Context, int, java.util.ArrayList)

后端 未结 3 653
谎友^
谎友^ 2021-01-26 17:59

I know this question has been asked a million times before, but I have tried all of the solutions I can find, and still doesn\'t work. I have tried calling \"this\" for context,

相关标签:
3条回答
  • 2021-01-26 18:26

    You probably should learn more about generics and type safety.

    Your reservations has type ArrayList<Reservation> but you try to create ArrayAdapter<Review> which is wrong. Change it to ArrayAdapter<Reservation>.

    0 讨论(0)
  • 2021-01-26 18:26

    You should pass an array of Review not an array of Reservation. So change your adapter to ArrayAdapter<Reservation>.

    Also, at the moment you call the getActivity() method inside the onCreateView() method your Activity is not created yet, which can cause an error. To solve this issue, you should to move this line to your onActivityCreated() :

    @Override
        public void onActivityCreated(@Nullable Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            context = getActivity();
        }
    
    0 讨论(0)
  • 2021-01-26 18:44

    Your Array Adapter is of Type Review

    ArrayAdapter<Review> arrayAdapter 
    

    But Your passing :

     ArrayList<Reservation> reservations
    Change it to ArrayAdapter<Reservation>
    
    0 讨论(0)
提交回复
热议问题