Android刷卡刷新动画保持旋转

时间:2016-03-13 12:16:11

标签: android

我已经在我的一个片段中实现了刷卡刷新。问题是刷新图标不断旋转,不刷新列表。我已实施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();
}

1 个答案:

答案 0 :(得分:3)

更改为:

@Override
public void onRefresh() {
    swipe.setRefreshing(false);
    adapter.notifyDataSetChanged();
}