-2

In continuation with the problem

Google Android tutorial - not compiling

The asList used while creating weekForecast variable is giving an error -- cannot resolve method .. ? I have used these header files apart from above solutions and support.v4 as well. Its not the complete program.

import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;


public static class PlaceholderFragment extends Fragment{
        public PlaceholderFragment(){

        }
        public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
            View rootView= inflater.inflate(R.layout.fragment_main,container);
            String[] forecastArray = {
                    "Today - Sunny - 88/63",
                    "Tomorrow - Foggy - 70/40",
                    "Weds - Cloudy - 72/63",
                    "Thurs - Asteroids - 75/65",
                    "Fri - Heavy Rain - 65/56",
                    "Sat - HELP TRAPPED IN WEATHERSTATION - 60/51",
                    "Sun - Sunny - 80/68"
            };
            List<String> weekForecast = new ArrayList<String>(Array.**asList**(forecastArray));
           ArrayAdapter mForecastAdapter = new ArrayAdapter<String>(getActivity(),R.layout.list_item_forecast,
                    R.id.list_item_forecast_textview,weekForecast);

            ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
            listView.setAdapter(mForecastAdapter);

            return rootView;
        }
    }
2Dee
  • 8,609
  • 7
  • 42
  • 53
  • [What should I do when someone answers my question?](http://stackoverflow.com/help/someone-answers) – 2Dee Jan 12 '16 at 16:04

2 Answers2

2

You're not using the correct helper class.

Instead of

Array.asList(forecastArray)

use

Arrays.asList(forecastArray)
2Dee
  • 8,609
  • 7
  • 42
  • 53
1

Change Array.**asList**(forecastArray) to Arrays.asList(forecastArray).

Take a look at Arrays.asList method.

Dhaval Patel
  • 10,119
  • 5
  • 43
  • 46