java - ANDROID: Update data in another activity in Master Detail Flow Layout -


i've searched solution question on internet haven't been able find 1 , hope can me out

i trying create master detail flow application in android 2 activities , second activity contains fragment. can please tell me how can simultaneously update value in mainactivity() when make change in fragment's edittext field? have tried using intent when 2 activities side side doesnt seem work well.

screenshot of emulator

any suggestions?

it seems in context follows:

when happens, triggers b

as result, suggest use eventbus library in project.

the installation easy. first, add following code in build.gradle file:

compile 'org.greenrobot:eventbus:3.0.0' 

second, let's see going add in our codes.

in fragment wanted make changes:

/* when happens */ mybutton.setonclicklistener(new view.onclicklistener() { // complete entering content, update     eventbus.getdefault.post(myupdateevent(mycontent)); }); 

create custom class myupdateeven:

public class myupdateevent{   private string mycontent;    public myupdateevent(string mycontent) {     this.mycontent = mycontent;   }    public string getupdatecontent() {     return mycontent;   }  } 

in activity wanted update:

@override     protected void oncreate(@nullable bundle savedinstancestate) {         super.oncreate(savedinstancestate);         eventbus.getdefault.register(this); // add code monitor update         }        /* triggers b */       @subscribe // don't forget add @subscribe       public void onevent(myupdateevent event){          // custom method          mytextview.settext(event.getupdatecontent()); // update        }        @override       protected void ondestroy() {           super.ondestroy();           eventbus.getdefault.unregister(this); // when leave lifecycle, cancel monitoring       } } 

eventbus library i've been used lot in projects. think can solve problem.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -