diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a4bb27364..c68dcaa01 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,15 +9,17 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> - - - + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/android/android_me/ui/AndroidMeActivity.java b/app/src/main/java/com/example/android/android_me/ui/AndroidMeActivity.java index ba552f613..dd0a6ba78 100644 --- a/app/src/main/java/com/example/android/android_me/ui/AndroidMeActivity.java +++ b/app/src/main/java/com/example/android/android_me/ui/AndroidMeActivity.java @@ -26,19 +26,6 @@ // This activity will display a custom Android image composed of three body parts: head, body, and legs public class AndroidMeActivity extends AppCompatActivity { - // TODO (1) Create a fragment_master_list.xml layout file to display all our images; this should be a GridView - - // TODO (2) Create a new class called MasterListFragment which will display the GridView list of ALL AndroidMe images - // In the fragment class, you'll need to implement an empty constructor, and onCreateView - - // TODO (3) In the MasterListFragment class, create a new MasterListAdapter and set it on the GridView - // The MasterListAdapter code is provided; it creates the ImageViews that are contained in the GridView - // The adapter takes as parameters (Context context, List imageIds) - - // After creating the fragment.. - // TODO (4) Create a new Activity named MainActivity and a corresponding layout file that displays a MasterListFragment - // Remember, to display a static fragment in a layout file, use the tag - @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/example/android/android_me/ui/MainActivity.java b/app/src/main/java/com/example/android/android_me/ui/MainActivity.java new file mode 100755 index 000000000..d854d5c3f --- /dev/null +++ b/app/src/main/java/com/example/android/android_me/ui/MainActivity.java @@ -0,0 +1,35 @@ +/* +* Copyright (C) 2017 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.example.android.android_me.ui; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +import com.example.android.android_me.R; + +// This activity is responsible for displaying the master list of all images +public class MainActivity extends AppCompatActivity { + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + } + +} diff --git a/app/src/main/java/com/example/android/android_me/ui/MasterListFragment.java b/app/src/main/java/com/example/android/android_me/ui/MasterListFragment.java new file mode 100755 index 000000000..7c9f210ca --- /dev/null +++ b/app/src/main/java/com/example/android/android_me/ui/MasterListFragment.java @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2017 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.example.android.android_me.ui; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.GridView; + +import com.example.android.android_me.R; +import com.example.android.android_me.data.AndroidImageAssets; + + +// This fragment displays all of the AndroidMe images in one large list +// The list appears as a grid of images +public class MasterListFragment extends Fragment { + + // Mandatory empty constructor + public MasterListFragment() { + } + + // Inflates the GridView of all AndroidMe images + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + final View rootView = inflater.inflate(R.layout.fragment_master_list, container, false); + + // Get a reference to the GridView in the fragment_master_list xml layout file + GridView gridView = (GridView) rootView.findViewById(R.id.images_grid_view); + + // Create the adapter + // This adapter takes in the context and an ArrayList of ALL the image resources to display + MasterListAdapter mAdapter = new MasterListAdapter(getContext(), AndroidImageAssets.getAll()); + + // Set the adapter on the GridView + gridView.setAdapter(mAdapter); + + // Return the root view + return rootView; + } + +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100755 index 000000000..70ace7801 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/app/src/main/res/layout/fragment_master_list.xml b/app/src/main/res/layout/fragment_master_list.xml new file mode 100755 index 000000000..af422d9e0 --- /dev/null +++ b/app/src/main/res/layout/fragment_master_list.xml @@ -0,0 +1,27 @@ + + + + + +