Layouts and Resources for the UI
M. Rizki Maulana
Himatif Talent
Session 2
Unsera, 14 September 2019
devemrizkiem@gmail.com
Layout View and ViewGroups
Views
ViewGroups
The layout editor
Activities
Intents
[n] An activity represents a single screen in your app with an interface the user can interact.
[n] Each activity is started or activated with an Intent, which is a message object that makes a request to the Android runtime to start an activity or other app component in your app or in some other app.
Activity lifecycle
ex :
Activity lifecycle
Saving activity state
Intents types
Intent object and fields
Fragment
Fragment lifecycle
Add fragment to activity
code :
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
HomeFragment homeFragment = new HomeFragment();
Fragment fragment = fragmentManager.findFragmentByTag(HomeFragment.class.getSimpleName());
if (!(fragment instanceof HomeFragment)) {
fragmentTransaction.add(R.id.frame_container, homeFragment, HomeFragment.class.getSimpleName());
fragmentTransaction.commit();
Resources
Thank you