Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

TFragments.02-Exercise-DisplayThreeFragments #27

Open
wants to merge 1 commit into
base: TFragments.01-Solution-CreateBodyPartFragment
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -34,11 +34,16 @@ protected void onCreate(Bundle savedInstanceState) {
// Create a new head BodyPartFragment
BodyPartFragment headFragment = new BodyPartFragment();

// TODO (4) Set the list of image id's for the head fragment and set the position to the second image in the list

// Add the fragment to its container using a FragmentManager and a Transaction
FragmentManager fragmentManager = getSupportFragmentManager();

fragmentManager.beginTransaction()
.add(R.id.head_container, headFragment)
.commit();

// TODO (5) Create and display the body and leg BodyPartFragments

}
}
Original file line number Diff line number Diff line change
@@ -28,6 +28,11 @@

public class BodyPartFragment extends Fragment {

// TODO (1) Create a setter method and class variable to set and store of a list of image resources

// TODO (2) Create another setter method and variable to track and set the index of the list item to display
// ex. index = 0 is the first image id in the given list , index 1 is the second, and so on

/**
* Mandatory empty constructor for the fragment manager to instantiate the fragment
*/
@@ -49,6 +54,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
// Set the image to the first in our list of head images
imageView.setImageResource(AndroidImageAssets.getHeads().get(0));

// TODO (3) If a list of image ids exists, set the image resource to the correct item in that list
// Otherwise, create a Log statement that indicates that the list was not found

// Return the rootView
return rootView;
}