2016-09-16 73 views
2

我只是創建一個簡單/空白片段,它應該使用Mosby框架。我使用的是getView()方法每次我得到的錯誤:Mosby Framework - getView cause ClassCastException

java.lang.ClassCastException: de.xxx.projectZ.packA.AFragment cannot be cast to 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> { 

不有人知道爲什麼發生這種情況?

回答

2

您的片段沒有實現AView ...

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

     implements AView // This is missing 
{ 
... 
} 
+0

媽...謝謝.. :) – Tobias