我正在使用 ListFragments .. 我想在列表为空但不显示时使用 setEmptyText() 继续显示进度 它一直显示进度条 我不知道包含此列表的布局的确切位置这是我的代码
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
new getData().execute();
}
private class getData extends AsyncTask<Void, Void, ArrayList<Object>> {
@Override
protected ArrayList<Object> doInBackground(Void... params) {
// TODO Auto-generated method stub
try {
artists = new ArrayList<Object>();
artists = loadArtists("taqwa.xml");
return loadXml("taqwa.xml");
} catch (XmlPullParserException e) {
e.printStackTrace();
Utils.log("XML exception", "true");
return null;
} catch (IOException e) {
e.printStackTrace();
Utils.log("IOException", "true");
return null;
}
}
@Override
protected void onPostExecute(ArrayList<Object> result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (result != null) {
ListAdapter ladapter = new ListAdapter(getActivity(),
R.layout.list_row, null, artists, 3);
setListAdapter(ladapter);
} else {
setEmptyText("not found wallahi!");
}
}
}
如您所见,我不使用包含 @id/android:list 之类的布局来添加 @id/android:empty .. 我只将列表项发送到 baseAdapter