On the Code
Activity implements a set of interfaces to manipulate the view
Public class mainactivity extends Activity implements TestView{ p in//MVP, a view can have multiple p, implementing multiple sets of business logic, such as the main interface also needs to read conversation content@Bean(Testactions.class) Itestactions testactions;@ViewById(R.id.btn_back) Button Btnback;@ViewById(R.id.btn_noback) Button Btnnoback;//testview interface for interface display, due to actions may be called inside the thread, need Uithread security@UiThread@Override Public void ShowName(String name) {Toast.maketext ( This, name, Toast.length_short). Show (); Btnback.settext ("clicked");}//Event 1@Click(R.id.btn_back) Public void Doinback() {Testactions.doinbackground ();}//Event 2@Click(R.id.btn_noback) Public void Donoback() {testactions.donoback ();}}
The view interface can implement multiple
Testactions implements the business logic and injects a TestView interface for the callback display
@EBean Public class testactions implements itestactions {**//Auto-inject UI view,fragment or activity,p view can have multiple, different view corresponding to different modules, this tag is extended to inject the view interface * *@ViewInterfaceTestView view;//Method 1, running through threads, background tasks@Override@Background Public void Doinbackground() {//Do some business here, call the view's showname display to the UIView.showname ("show in the back Ground2");}//Method 2, run in UI main thread@Override Public void Donoback() {View.showname ("Show in No");}}
TestView interface
publicvoidshowName(String name);
Extended Androidannotations Programming with MVP mode