我已经在我的一个片段中实现了刷卡刷新。问题是刷新图标不断旋转,不刷新列表。我已实施onRefresh()
来调用notifyDataSetChanged()
,但这似乎没有刷新列表
填充列表&滑动视图
swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe);
swipe.setOnRefreshListener(this);
cursor = db.getAllItems();
String[] values = new String[cursor.getCount()];
cursor.moveToFirst();
for(int i = 0; i < cursor.getCount(); i++)
{
String row = cursor.getString(cursor.getColumnIndex("name"));
values[i] = row;
cursor.moveToNext();
}
final String[] columns = new String[] {db.KEY_ITEM_NAME, db.KEY_MEASUREMENT, db.KEY_UNIT};
int[] to = new int[] {R.id.ingredientName, R.id.ingredientMeasurement, R.id.ingredientUnit};
adapter = new ShoppingCustomAdapter(getActivity(), R.layout.shopping_list_row, cursor, columns, to);
setListAdapter(adapter);
onRefresh
@Override
public void onRefresh() {
adapter.notifyDataSetChanged();
}
答案 0 :(得分:3)
更改为:
@Override
public void onRefresh() {
swipe.setRefreshing(false);
adapter.notifyDataSetChanged();
}