Android MVP

你们先看看目录结构html

 

 先看V层

 View里面我写了一个接口LoginViewgit

 

而后,在登陆这个Activity 去实现这个接口,并实现其抽象方法。即看LoginActivitygithub

onCreate中引用了P网络

loginPresenter = new LoginPresenter(this);

view层点击事件条用了P层ide

@Override
public void onClick(View view) {
     switch ( view.getId() ) {
         case R.id.btn_login:
              loginPresenter.login();
              break;
          default:
                break;

     }
}

咱们再看P层。

最后M层

model里面我写了一个接口LoginModel,一个实现类LoginModelImple而后还有一个接口OnLoginListenerui

  先看LoginModel--登陆接口this

 

再看LoginModelImple--登陆Model实现,这里主要是网络请求的操做。.net

 

 OnLoginListener--监听器用来处理Model实现后的操做htm

github:https://github.com/ganchuanpu/MVPDemoblog

 

友情连接:http://blog.csdn.net/cym492224103/article/details/38776873?utm_source=tuicool

相关文章
相关标签/搜索