cashloveyou
@cashloveyou
Хороший чел

Error: no suitable method found for setAdapter?

Добрый вечер при компиляции приложения вылетают ошибки что я делаю неправильно?

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

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) {
            }

и 1232

public void onResponse(Call<ReactResponse> call, retrofit2.Response<ReactResponse> response) {
                reactorsAdapter.addAll(((ReactResponse) response.body()).getMembers());
            }
        });
        builder.create().show();
    }
  • Вопрос задан
  • 295 просмотров
Решения вопроса 1
zagayevskiy
@zagayevskiy Куратор тега Java
Android developer at Yandex
final Object reactorsAdapter = new ReactorsAdapter

Учи джаву. Здесь ты задекларировал, что reactorsAdapter - это Object. Должно быть ReactorsAdapter reactorsAdapter = ...
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы