Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
/* | ||
* Copyright (C) 2014 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.sunshine.app; | ||
|
||
import android.support.v7.app.ActionBarActivity; | ||
import android.support.v4.app.Fragment; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
|
||
|
||
public class MainActivity extends ActionBarActivity { | ||
|
||
|
@@ -55,7 +75,19 @@ public PlaceholderFragment() { | |
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
Bundle savedInstanceState) { | ||
|
||
// Create some dummy data for the ListView. Here's a sample weekly forecast | ||
String[] data = { | ||
"Mon 6/23 - Sunny - 31/17", | ||
"Tue 6/24 - Foggy - 21/8", | ||
"Wed 6/25 - Cloudy - 22/17", | ||
"Thurs 6/26 - Rainy - 18/11", | ||
"Fri 6/27 - Foggy - 21/10", | ||
"Sat 6/28 - TRAPPED IN WEATHERSTATION - 23/18", | ||
"Sun 6/29 - Sunny - 20/7" | ||
}; | ||
List<String> weekForecast = new ArrayList<String>(Arrays.asList(data)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lswank
|
||
View rootView = inflater.inflate(R.layout.fragment_main, container, false); | ||
return rootView; | ||
} | ||
|
2 comments
on commit de032c1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because if you use
List weekForecast = Arrays.asList(data);
the resulting weekForecast array will be fixed in size. If you use
List weekForecast = new ArrayList(Arrays.asList(data));
you can still change the size of the weekForecast array after adding the data.
Reference:
http://stackoverflow.com/questions/157944/create-arraylist-from-array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielKaparunakis, good point, thank you!
Though I don't think here is the case, it definitely can be in possible future, and so it is a good reason to wrap into ArrayList and maybe to have such habit at first.
what is line no. 92
I m not able to understand.