{"action":"created","issue":{"url":"https://api.github.com/repos/udacity/Sunshine-Version-2/issues/109","labels_url":"https://api.github.com/repos/udacity/Sunshine-Version-2/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/udacity/Sunshine-Version-2/issues/109/comments","events_url":"https://api.github.com/repos/udacity/Sunshine-Version-2/issues/109/events","html_url":"https://github.com/udacity/Sunshine-Version-2/issues/109","id":123906925,"number":109,"title":"The layout is not the same as one from the end of lesson 1?","user":{"login":"exocore123","id":16423765,"avatar_url":"https://avatars.githubusercontent.com/u/16423765?v=3","gravatar_id":"","url":"https://api.github.com/users/exocore123","html_url":"https://github.com/exocore123","followers_url":"https://api.github.com/users/exocore123/followers","following_url":"https://api.github.com/users/exocore123/following{/other_user}","gists_url":"https://api.github.com/users/exocore123/gists{/gist_id}","starred_url":"https://api.github.com/users/exocore123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exocore123/subscriptions","organizations_url":"https://api.github.com/users/exocore123/orgs","repos_url":"https://api.github.com/users/exocore123/repos","events_url":"https://api.github.com/users/exocore123/events{/privacy}","received_events_url":"https://api.github.com/users/exocore123/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-26T03:53:09Z","updated_at":"2015-12-26T19:05:07Z","closed_at":null,"body":"Hi, I am not sure what I did wrong, I basically copied and paste the code from the lesson when I was doing my project. The turn out of my code does not look like what the class has so far? Is it the version of my simulation? I am currently doing this in Jelly Bean, while the lesson is using Gingerbread. My simulation does not have settings implemented when I already have done what the code should be?\r\n\r\n![untitled](https://cloud.githubusercontent.com/assets/16423765/12005049/19fb1380-ab51-11e5-892f-4c4e5aad50cc.png)\r\n\r\n\r\nThis is my MainActivity.java\r\n\r\n    package com.dev.xxxxx.sunshine;\r\n\r\n    import android.os.Bundle;\r\n    import android.support.v7.app.AppCompatActivity;\r\n    import android.view.Menu;\r\n    import android.view.MenuItem;\r\n\r\n\r\n\r\n    public class MainActivity extends AppCompatActivity {\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n        if (savedInstanceState == null) {\r\n            getSupportFragmentManager().beginTransaction()\r\n                    .add(R.id.container, new ForecastFragment())\r\n                    .commit();\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public boolean onCreateOptionsMenu(Menu menu) {\r\n        // Inflate the menu; this adds items to the action bar if it is present.\r\n        getMenuInflater().inflate(R.menu.main, menu);\r\n        return true;\r\n    }\r\n\r\n    @Override\r\n    public boolean onOptionsItemSelected(MenuItem item) {\r\n        // Handle action bar item clicks here. The action bar will\r\n        // automatically handle clicks on the Home/Up button, so long\r\n        // as you specify a parent activity in AndroidManifest.xml.\r\n        int id = item.getItemId();\r\n\r\n        //noinspection SimplifiableIfStatement\r\n        if (id == R.id.action_settings) {\r\n            return true;\r\n        }\r\n\r\n        return super.onOptionsItemSelected(item);\r\n    }\r\n\r\n    /**\r\n     * A placeholder fragment containing a simple view.\r\n     */\r\n\r\n    }\r\n\r\n\r\n\r\n\r\n![untitled2](https://cloud.githubusercontent.com/assets/16423765/12005059/db7eb2aa-ab51-11e5-8df7-6cf31df14b5a.png)\r\n"},"comment":{"url":"https://api.github.com/repos/udacity/Sunshine-Version-2/issues/comments/167354965","html_url":"https://github.com/udacity/Sunshine-Version-2/issues/109#issuecomment-167354965","issue_url":"https://api.github.com/repos/udacity/Sunshine-Version-2/issues/109","id":167354965,"user":{"login":"exocore123","id":16423765,"avatar_url":"https://avatars.githubusercontent.com/u/16423765?v=3","gravatar_id":"","url":"https://api.github.com/users/exocore123","html_url":"https://github.com/exocore123","followers_url":"https://api.github.com/users/exocore123/followers","following_url":"https://api.github.com/users/exocore123/following{/other_user}","gists_url":"https://api.github.com/users/exocore123/gists{/gist_id}","starred_url":"https://api.github.com/users/exocore123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exocore123/subscriptions","organizations_url":"https://api.github.com/users/exocore123/orgs","repos_url":"https://api.github.com/users/exocore123/repos","events_url":"https://api.github.com/users/exocore123/events{/privacy}","received_events_url":"https://api.github.com/users/exocore123/received_events","type":"User","site_admin":false},"created_at":"2015-12-26T19:05:07Z","updated_at":"2015-12-26T19:05:07Z","body":"It looks like I do not. Where should I add this?\r\n\r\n\r\npackage com.dev.bao.sunshine;\r\n\r\nimport android.os.AsyncTask;\r\nimport android.os.Bundle;\r\nimport android.support.v4.app.Fragment;\r\nimport android.util.Log;\r\nimport android.view.LayoutInflater;\r\nimport android.view.View;\r\nimport android.view.ViewGroup;\r\nimport android.widget.ArrayAdapter;\r\nimport android.widget.ListView;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\nimport java.io.InputStreamReader;\r\nimport java.net.HttpURLConnection;\r\nimport java.net.URL;\r\nimport java.util.ArrayList;\r\nimport java.util.Arrays;\r\nimport java.util.List;\r\n\r\n    public class ForecastFragment extends Fragment {\r\n\r\n    ArrayAdapter<String> mForecastAdapter;\r\n\r\n    public ForecastFragment() {\r\n    }\r\n\r\n    @Override\r\n    public View onCreateView(LayoutInflater inflater, ViewGroup container,\r\n                             Bundle savedInstanceState) {\r\n\r\n        // Create some dummy data for the ListView.  Here's a sample weekly forecast\r\n        String[] data = {\r\n                \"Mon 6/23 - Sunny - 31/17\",\r\n                \"Tue 6/24 - Foggy - 21/8\",\r\n                \"Wed 6/25 - Cloudy - 22/17\",\r\n                \"Thurs 6/26 - Rainy - 18/11\",\r\n                \"Fri 6/27 - Foggy - 21/10\",\r\n                \"Sat 6/28 - TRAPPED IN WEATHERSTATION - 23/18\",\r\n                \"Sun 6/29 - Sunny - 20/7\",\r\n                \"Mon 6/30 - Sunny - 45/40\",\r\n                \"Tue 7/1 - Rainy - 30/18\"\r\n        };\r\n        List<String> weekForecast = new ArrayList<String>(Arrays.asList(data));\r\n\r\n\r\n        mForecastAdapter = new ArrayAdapter<String>(\r\n                getActivity(),\r\n                R.layout.list_item_forecast,\r\n                R.id.list_item_forecast_textview,\r\n                weekForecast);\r\n        View rootView = inflater.inflate(R.layout.activity_main, container, false);\r\n\r\n        ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);\r\n        listView.setAdapter(mForecastAdapter);\r\n        return rootView;\r\n\r\n    }\r\n    public class FetchWeatherTask extends AsyncTask<Void, Void, Void> {\r\n        private final String LOG_TAG = FetchWeatherTask.class.getSimpleName();\r\n\r\n        HttpURLConnection urlConnection = null;\r\n        BufferedReader reader = null;\r\n\r\n        // Will contain the raw JSON response as a string.\r\n        String forecastJsonStr = null;\r\n\r\n\r\n            @Override\r\n            protected Void doInBackground(Void... params) {\r\n                // These two need to be declared outside the try/catch\r\n                // so that they can be closed in the finally block.\r\n                HttpURLConnection urlConnection = null;\r\n                BufferedReader reader = null;\r\n\r\n                // Will contain the raw JSON response as a string.\r\n                String forecastJsonStr = null;\r\n\r\n                try {\r\n                    // Construct the URL for the OpenWeatherMap query\r\n                    // Possible parameters are avaiable at OWM's forecast API page, at\r\n                    // http://openweathermap.org/API#forecast\r\n                    String baseUrl = \"http://api.openweathermap.org/data/2.5/forecast/city?id=524901\";\r\n                    String apiKey = \"&APPID=\" + BuildConfig.OPEN_WEATHER_MAP_API_KEY;\r\n                    URL url = new URL(baseUrl.concat(apiKey));\r\n\r\n                    // Create the request to OpenWeatherMap, and open the connection\r\n                    urlConnection = (HttpURLConnection) url.openConnection();\r\n                    urlConnection.setRequestMethod(\"GET\");\r\n                    urlConnection.connect();\r\n\r\n                    // Read the input stream into a String\r\n                    InputStream inputStream = urlConnection.getInputStream();\r\n                    StringBuffer buffer = new StringBuffer();\r\n                    if (inputStream == null) {\r\n                        // Nothing to do.\r\n                        return null;\r\n                    }\r\n                    reader = new BufferedReader(new InputStreamReader(inputStream));\r\n\r\n                    String line;\r\n                    while ((line = reader.readLine()) != null) {\r\n                        // Since it's JSON, adding a newline isn't necessary (it won't affect parsing)\r\n                        // But it does make debugging a *lot* easier if you print out the completed\r\n                        // buffer for debugging.\r\n                        buffer.append(line + \"\\n\");\r\n                    }\r\n\r\n                    if (buffer.length() == 0) {\r\n                        // Stream was empty.  No point in parsing.\r\n                        return null;\r\n                    }\r\n                    forecastJsonStr = buffer.toString();\r\n                } catch (IOException e) {\r\n                    Log.e(LOG_TAG, \"Error \", e);\r\n                    // If the code didn't successfully get the weather data, there's no point in attemping\r\n                    // to parse it.\r\n                    return null;\r\n                } finally {\r\n                    if (urlConnection != null) {\r\n                        urlConnection.disconnect();\r\n                    }\r\n                    if (reader != null) {\r\n                        try {\r\n                            reader.close();\r\n                        } catch (final IOException e) {\r\n                            Log.e(LOG_TAG, \"Error closing stream\", e);\r\n                        }\r\n                    }\r\n                }\r\n                return null;\r\n            }\r\n        }\r\n\r\n    }"}}