大家好我的代码有问题...我已将myTask移到Splashscreen.java中.. 这是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);
第103行是
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);
答案 0 :(得分:1)
您应该从Fragment.getView()获取布局,而不是使用getActivity()。
<强>更新强>
因此,您将在Activity的onCreate中启动AsyncTask。可以在调用Fragment的onCreateView之前调用AsyncTask的onPostExecute,这是我怀疑在这里发生的事情;因此空指针。通常,这些是使用AsyncTasks的一些细微差别。
您有几种选择: