我试图将Mainactivity作为视图传递给演示者
(In MainActivity)
mainPresenter = new MainPresenter(this);
(Presenter cont)
public MainPresenter(View view) {
this.view = view;
user = new User();
}
但是,这个抛出错误是无效的铸造之类的东西。 我错过了什么吗?
该代码来自here
答案 0 :(得分:1)
你应该有类似的东西:
public interface YourView {
void doSomething();
}
public MainActivity extends Activity implements YourView {
mainPresenter = new MainPresenter(this);
}
public MainPresenter(YourView view) {
this.view = view;
view.doSomething();
}