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
Post a Comment