android - inter fragment Communication -


my question if com reference of interface communicater why used getactivity(); in com = (communicater)getactivity(); .. thanks

public class fragmenta extends fragment implements view.onclicklistener{ button button; int counter; communicater com;  @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     return inflater.inflate(r.layout.fragment_a,container,false);  }  @override public void onactivitycreated(bundle savedinstancestate) {     super.onactivitycreated(savedinstancestate);     button = (button) getactivity().findviewbyid(r.id.button);     com= (communicater) getactivity();     button.setonclicklistener(this); }  @override public void onclick(view v) {     counter++;     com.respond("this button clicked "+counter+" times"); } 


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -