Can I use the same button on multiple Android activities and return to original activity? -
i'm new android , making very, rough sketch of how app display information users. making app not providing text displays.
what want have multiple activities text box , underneath have button using oncreate
method (i believe correct method) have exact same button on each activity linking main activity. want make don't have recreate intent or button code on every page, make single line "display button id=home" on each activity. want make simple possible because i'll making a lot of activities text display.
when figure out i'm going drop buttons , use navigation drawer access info need draft team start organizing information displays.
i hope explaining final product can show want do. in advance!
create button programmatically.
linearlayout.layoutparams layoutparams = new linearlayout.layoutparams(layoutparams.wrap_content,layoutparams.wrap_content); button button1 = createbutton(this); layout.addview(button1); public static button createbutton(activity a) { button b = new button(a); b.setlayoutparams(layoutparams); b.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent intent = new intent(a.class.this, mainactivity.class); startactivity(intent); } }) return b; }
Comments
Post a Comment