I have an activity with fragment which contains ListView, the app is building and deploying without problem but i get the APP HAS STOPPED working message when i populate the listView.
If i comment out the listview population with the adapter, the app runs without any problem.
This is the code:
public class MainActivityFragment extends Fragment {
private ArrayAdapter<String> weather_adapter;
public MainActivityFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
String[] data = {
"item1",
"item2"
};
List<String> list = new ArrayList<String>(Arrays.asList(data));
weather_adapter = new ArrayAdapter<String>(
getActivity(),
R.layout.l_list_item,
R.id.list_view,
list );
ListView welist =
(ListView)rootView.findViewById(R.id.list_view);
wlist.setAdapter(adapter);
return rootView;
}
}
Do you have any idea how to detect what is wrong since stacktrace doesnt throw any errors or warnings?