S
S
Sergey Defactov2018-03-01 18:17:13
Java
Sergey Defactov, 2018-03-01 18:17:13

Error: no suitable method found for setAdapter?

Good evening, when compiling the application, errors fly out, what am I doing wrong?

java:1226: error: no suitable method found for setAdapter(Object)
        listView.setAdapter(reactorsAdapter);
                ^
    method AdapterView.setAdapter(ListAdapter) is not applicable
      (argument mismatch; Object cannot be converted to ListAdapter)
    method AbsListView.setAdapter(ListAdapter) is not applicable
      (argument mismatch; Object cannot be converted to ListAdapter)
    method ListView.setAdapter(ListAdapter) is not applicable
      (argument mismatch; Object cannot be converted to ListAdapter)
com\procrea8\mabtribune\modules\feed\adapter\FeedAdapter.java:1232: error: cannot find symbol
                reactorsAdapter.addAll(((ReactResponse) response.body()).getMembers());

java code
public void showReactorsDialog(int i) {
        FeedResponse feedResponse = (FeedResponse) this.feedLists.get(i);
        Builder builder = new Builder(this.context);
        View inflate = this.layoutInflater.inflate(R.layout.reactors_dialog, null);
        builder.setView(inflate);
        builder.setTitle((CharSequence) "People who react to this");
        ListView listView = (ListView) inflate.findViewById(R.id.reactorLists);
        final Object reactorsAdapter = new ReactorsAdapter(this.context, new ArrayList());
      226 строчка >>>>   listView.setAdapter(reactorsAdapter);
        ((LikeApiInterface) Api.getRetrofit().create(LikeApiInterface.class)).getReacts("feed", feedResponse.getFeedId(), "50").enqueue(new Callback<ReactResponse>() {
            public void onFailure(Call<ReactResponse> call, Throwable th) {
            }

and 1232
public void onResponse(Call<ReactResponse> call, retrofit2.Response<ReactResponse> response) {
                reactorsAdapter.addAll(((ReactResponse) response.body()).getMembers());
            }
        });
        builder.create().show();
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-03-01
@cashloveyou

final Object reactorsAdapter = new ReactorsAdapter

Learn Java. Here you declared that reactorsAdapter is an Object. Should be ReactorsAdapter reactorsAdapter = ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question