Android Facebook Integration without Fragments -
i creating social app , have integration facebook can grab information on friends, user info, post on users wall , upload picture facebook. have followed tutorials on facebook website using fragments. prefer not use fragments if @ possible. i'm sure facebook wouldn't tie api around use of fragments shut out people.
i understand clear answer use newest api fragments rather not following reasons:
- i don't see why wouldn't able without fragments.
- i don't entirely understand point fragments , why becoming increasingly more popular.
- i have of application implemented without using fragments , implement facebook login/use @ point in development.
that being said, how can go doing without use of fragments?
why fragments becoming increasingly popular?
if answer use facebook api fragments, there "easy" way alter app i've created, uses activities, uses fragments?
cheers,
jake
if want sample reference on how switch activities fragments. i'm adding example activity , fragments.
// activity class have convert fragments testactivity.java public class testactivity extends activity implements onclicklistener { private static edittext edittext; private static button button; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_first); edittext = (edittext) findviewbyid(r.id.et_price); button = (button) findviewbyid(r.id.bt_bold); button.setonclicklistener(this); } @override public void onclick(view v) { // todo auto-generated method stub if(v.equals(button)) { edittext.settext("arshad's test app"); } } }
now converting testactivity fragment need make in 2 classes. testactivity.java , testfragment.java
// testactivity extend fragmentactivity instead of activity public class testactivity extends fragmentactivity { private testfragment testfragment_object; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if (savedinstancestate == null) { // add fragment on initial activity setup testfragment_object = new testfragment(); getsupportfragmentmanager().begintransaction() .add(android.r.id.content, testfragment_object).commit(); } else { // or set fragment restored state info testfragment_object = (testfragment) getsupportfragmentmanager() .findfragmentbyid(android.r.id.content); } } }
now fragment class contain code of layouts , actions performed in class contained in activity class earlier.
testfragment.java public class testfragment extends fragment implements onclicklistener { private static edittext edittext; private static button button; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.activity_first, container, false); edittext = (edittext) view.findviewbyid(r.id.et_price); button = (button) view.findviewbyid(r.id.bt_bold); button.setonclicklistener(this); return view; } @override public void onclick(view v) { // todo auto-generated method stub if(v.equals(button)) { edittext.settext("arshad's test app"); } } }
Comments
Post a Comment