java - How to get Button click from Fragments -
i got fragment need take buttonclick.
problem click going mainactivity hosting fragments , not fragment itself. have tried loging , nothing shows in logs when click button.
i show u entire oncreateview.
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.server_settings, container, false); final button loginbutton = (button) view.findviewbyid(r.id.addserversettingsbtn); loginbutton.setonclicklistener(new onclicklistener() { @override public void onclick(final view v) { //were magic won't happen. } }); return inflater.inflate(r.layout.server_settings, container,false); }
your problem (i believe) you're returning instance of inflated view doesn't have onclick handler assigned.
try this:
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.server_settings, container, false); final button loginbutton = (button) view.findviewbyid(r.id.addserversettingsbtn); loginbutton.setonclicklistener(new onclicklistener() { @override public void onclick(final view v) { //were magic won't happen. } }); return view; }
Comments
Post a Comment