【问题标题】:Mosby Framework - getView cause ClassCastExceptionMosby 框架 - getView 导致 ClassCastException
【发布时间】:2016-09-16 11:29:22
【问题描述】:

我只是创建了一个简单/空白片段,它应该使用MosbyFramework。每次我使用 getView()method 时都会出现错误:

java.lang.ClassCastException: de.xxx.projectZ.packA.AFragment 不能转换为 de.xxx.projectZ.packA.AView

public interface AView extends MvpLceView<List<Persons>> {
  // empty
}

我的演示者导致错误

public class APresenter extends MvpBasePresenter<AView> {
    PersonsRepository personsRepository;

    @Inject
    public APresenter(PersonsRepositoryImpl personsRepository) {
        this.personsRepository = personsRepository;
    }

    public void loadPersons() {
// ERROR
        if (isViewAttached())
            getView().showLoading(true);

        List<Person> persons = personsRepository.getPersons();


        if (isViewAttached()) {

        }
    }
}

我的片段标题

public class PersonsFragment
        extends MvpLceFragment<SwipeRefreshLayout, List<Person>, AView, APresenter> {

有人知道为什么会这样吗?

【问题讨论】:

    标签: java android mosby


    【解决方案1】:

    您的 Fragment 没有实现 AView ...

    public class PersonsFragment
            extends MvpLceFragment<SwipeRefreshLayout, List<Person>, AView, APresenter> 
    
            implements AView  // This is missing
    {
     ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-10
      • 2021-04-29
      • 2016-03-14
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多