java - Android Development, Google Tutorial -
java - Android Development, Google Tutorial -
i next google tutorial building first android application. got point needed implement actionbar actions functions opensearch() , opensettings().
i implemented of in mainactivity.java file.
my question this:
in illustration app can type message , send , displays in sec activity. in sec activity, top action bar changes , not display search icon or perform action when settings button clicked. in order have these icons displayed in action bar activity well, need add together methods , update onoptionsitemselected method in displaymessageactivity.java in mainactivity.java? way carry action bar icons/actions over? retype same methods in each activity want them in? or there improve way it?
my other related curiosity this. method opensettings() called when click 3 vertical dots , settings. these 3 vertical dots show on every activity, , settings in list. clicking settings doesn't perform phone call opensettings() when in displaymessageactivity , not mainactivity. how settings , vertical dots carried over?
second last, how can add together other selections drop downwards list options/vertical dots in action bar? settings there although responds differently in each activity first question. add together things options menu on activities, , things unique activities. assume there must improve way repeating switch statements , methods in every activity.java file.
and finally, best practice implement action bar on multiple activities?
obviously different activities have different icons/actions in action bar, things 3 vertical dots(options) , settings within acceptable have in every activity, while nice add together other things options list don't see why settings should ever alter across activities. yet stated before method not called in displaymessageactivity unless repeat code in displaymessageactivity.java had added mainactivity.java. i'm confused can add together these displayed on activities without repeating code. , i'm confused how actionbar's options/vertical dots carried on activities while others require repeating of code in each activities' java file want them show in.
i know bit of long winded quesiton, clarify if necessary. i'm bit confused. able create through tutorial fine have decent understanding of java. google's guide isn't written , android environment confusing beginner.
i understand how things work degree, want ensure i'm doing in way when app grows in complexity won't mess of unnecessarily repeated statements , methods.
thanks in advance assistance , tips.
in order have these icons displayed in action bar activity well, need add together methods , update onoptionsitemselected method in displaymessageactivity.java in mainactivity.java? way carry action bar icons/actions over? retype same methods in each activity want them in? or there improve way it?
that 1 solution, know, it's not one. there @ to the lowest degree 2 alternative solutions:
create menuactivity
class implements logic mutual menu items , extend class of activities, rather extending standard activity
class.
use fragments implement ui. fragments similar activities in create ui elements xml layout. 1 difference live within "host activity". in particular case, host activity provide mutual menu functionality , each fragment can customize farther depending on needs.
how settings , vertical dots carried over?
most displaymessageactivity
overrides oncreateoptionsmenu()
, inflates menu xml layout created android studio (or eclipse?) when created activity class.
java android
Comments
Post a Comment