Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AndroidMeActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_android_me);
- // Only create new fragments when there is no previously saved state
- if(savedInstanceState == null) {
- // Create a new head BodyPartFragment
- BodyPartFragment headFragment = new BodyPartFragment();
- // Set the list of image id's for the head fragment and set the position to the second image in the list
- headFragment.setImageIds(AndroidImageAssets.getHeads());
- headFragment.setListIndex(1);
- // Add the fragment to its container using a FragmentManager and a Transaction
- FragmentManager fragmentManager = getSupportFragmentManager();
- fragmentManager.beginTransaction()
- .add(R.id.head_container, headFragment)
- .commit();
- // Create and display the body and leg BodyPartFragments
- BodyPartFragment bodyFragment = new BodyPartFragment();
- bodyFragment.setImageIds(AndroidImageAssets.getBodies());
- fragmentManager.beginTransaction()
- .add(R.id.body_container, bodyFragment)
- .commit();
- BodyPartFragment legFragment = new BodyPartFragment();
- legFragment.setImageIds(AndroidImageAssets.getLegs());
- fragmentManager.beginTransaction()
- .add(R.id.leg_container, legFragment)
- .commit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement