Android 6.0 drop-down refresh, SwipeRefreshLayout

1.android6.0 summary pullTorefresh new controls SwipeRefreshLayout, pull-down refresh drops Bang Bang

The first is the XML

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/id_swipe_ly"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <GridView
            android:id="@+id/gridView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:background="@color/white"
            android:listSelector="@color/text_f6"
            android:numColumns="2"
            android:stretchMode="columnWidth" >
        </GridView>
    </android.support.v4.widget.SwipeRefreshLayout>

2.Actitvity

public class BrandShowActivity extends AppBaseHeaderActivity implements SwipeRefreshLayout.OnRefreshListener {

    @ViewInject(R.id.gridView)
    GridView gridView;
    @ViewInject(R.id.id_swipe_ly)
    SwipeRefreshLayout mSwipeLayout;


    private ItemAdapter itemAdapter;

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.brandshow);
        ViewUtils.inject(this);

        initTopBarForLeft("品牌show");

        itemAdapter = new ItemAdapter(this);

        getItemData();

        mSwipeLayout.setOnRefreshListener(this);

    }

    public void getItemData() {
        List<Item> ctrList = new ArrayList<Item>();
        ctrList.add(new Item(1, R.drawable.home_item_1, "安远网商"));
        ctrList.add(new Item(2, R.drawable.home_item_2, "乐购安远"));
        ctrList.add(new Item(3, R.drawable.home_item_3, "物流中心"));
        ctrList.add(new Item(4, R.drawable.home_item_4, "产品溯源"));
        ctrList.add(new Item(5, R.drawable.home_item_5, "电商学院"));
        ctrList.add(new Item(6, R.drawable.home_item_6, "便民服务"));
        ctrList.add(new Item(7, R.drawable.home_item_6, "便民服务"));
        ctrList.add(new Item(8, R.drawable.home_item_6, "便民服务"));
        itemAdapter.setData(ctrList);
        gridView.setAdapter(itemAdapter);
    }

    @Override
    public void onRefresh() {
        mHandler.sendEmptyMessageDelayed(1, 1000);
    }

    private Handler mHandler = new Handler() {
        public void handleMessage(android.os.Message msg) {
            switch (msg.what) {
                case 1:
                    getItemData();
                    mSwipeLayout.setRefreshing(false);
                    break;
            }
        }
    };


}

3. Bang Bang drip drop-down effect can change the color, do not just set a color, personal feel more hyun

//, android.R.color.holo_purple, android.R.color.holo_orange_light, android.R.color.holo_red_light
mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_bright);



Published 40 original articles · won praise 19 · views 60000 +

Guess you like

Origin blog.csdn.net/u010090644/article/details/50147847