未调用自定义Adapter getView()方法下面是我正在为列表设置自定义适配器的片段的代码。除了ListView是空的。我已经实施了getCount()它返回我的ArrayList中正确的项目数。我看不出来("Inside", "GetView")在夜猫子里碎片public class ServiceCarListFragment extends Fragment {
private String url;
private ArrayList<CarDetail> carDetailList = new ArrayList<CarDetail>();
private CarListAdapter adapter;
private ListView mList;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
url = getActivity().getIntent().getStringExtra("url");
new DownloadCarDetail().execute(url);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View v = inflater.inflate(R.layout.fragment_service_car_list, container, false);
mList = (ListView) v.findViewById(R.id.list);
mList.setAdapter(adapter);
for (CarDetail car : carDetailList) {
// START LOADING IMAGES FOR EACH STUDENT
car.loadImage(adapter);
}
return v;
}
class DownloadCarDetail extends AsyncTask<String, String, ArrayList<CarDetail>> {
@Override
protected ArrayList<CarDetail> doInBackground(String... params) {
// TODO Auto-generated method stub
ArrayList<CarDetail> carDetailList = JsonParser.parseJson(params[0]);
return carDetailList;
}
@Override
protected void onPostExecute(ArrayList<CarDetail> carDetailList) {
// TODO Auto-generated method stub
ServiceCarListFragment.this.carDetailList = carDetailList;
Log.d("dccs", String.valueOf(ServiceCarListFragment.this.carDetailList.size()));
adapter = new CarListAdapter(getActivity(), ServiceCarListFragment.this.carDetailList);
Log.d("dccs", String.valueOf((adapter.getCount())));
}
}
- 3 回答
- 0 关注
- 440 浏览
添加回答
举报
0/150
提交
取消