问题在于第一个适配器构造的显示被第二个适配器构造的显示替换,当它获得数据时,它是通过mAdapter2.changeCursor(cursor)加载的数据。
My Fragment在单个布局中有两个ListView,它们在onCreateView方法中被夸大。
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout with two list views
View view = inflater.inflate(R.layout.fragment_shipment_details, null);
// Define list view for shipment details
ListView lis1 = (ListView) view.findViewById(R.id.list1);
mAdapter1 = new CursorAdapter1(getActivity(), null, 1);
list1.setAdapter(mAdapter1);
// Define list view for event list
ListView list2 = (ListView) view.findViewById(R.id.list2);
mAdapter2 = new CursorAdapter2(getActivity(), null, 1);
eventView.setAdapter(mAdapter1);
return view;
然后使用两个游标加载数据,这是正常工作,直到在onLoadFinished(Loader cursorLoader,Cursor游标)中调用第二个适配器。
两个适配器都有newVies和bindView。
第一个适配器:
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.details_layout1, parent);
}
第二个适配器:
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.details_layout2, parent);
}
如何解决适配器不覆盖?