Reputation: 95
Hi guys i have a problem with my code... i have moved myTask into Splashscreen.java.. this is arrivi.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View arrivi = inflater.inflate(R.layout.arrivi, container, false);
return arrivi;
}
public void CheckRow(){
ListView list;
rowItems = new ArrayList<RowItem>();
for (int i = 1; i <= thread; i++) {
RowItem item = new RowItem(Compagnia[i], CodiceVolo[i], Citta[i],OraPrevista[i], OraStimata[i], StatoVolo[i]);
rowItems.add(item);
System.out.println(CodiceVolo[i]);
}
list=(ListView)arrivi.findViewById(R.id.listView1);
CustomBaseAdapter adapter = new CustomBaseAdapter(getActivity(), rowItems);
list.setAdapter(adapter);
line 103 is
list=(ListView)getActivity().findViewById(R.id.listView1);
SplashScreen.java
public class SplashScreen extends Activity {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.splashscreen);
Upvotes: 0
Views: 68
Reputation: 4907
Instead of using getActivity(), you should be getting the layout from the Fragment.getView().
Update
So, you're launching your AsyncTask in the onCreate of your Activity. The AsyncTask's onPostExecute can get called before your Fragment's onCreateView gets called, which is what I suspect is happening here; hence the null pointer. In general, these are some of the nuances of using AsyncTasks.
You have several options:
Checkout this link for more info.
Upvotes: 1