[Solved] ListView returning null using Fragment


This is happening because you are using the wrong View variable to find the ListView.

ListView lv = (ListView) view.findViewById(R.id.lvAlerts);

The view variable here refers to:

public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

You need to refer to this view:

view = inflater.inflate(R.layout.tab_frag_alerts, container, false);

You should change the declaration:

View view;    //change view to some other name

Or,

public void onItemSelected(AdapterView<?> parent, View someOtherView, int pos, long id) {

0

solved ListView returning null using Fragment