Search in sources :

Example 1 with HeadAndFootAdapter

use of xyz.zpayh.myadapter.adapter.HeadAndFootAdapter in project SherlockAdapter by EvilBT.

the class HeadAndFootActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_head_and_foot);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new HeadAndFootAdapter(this);
    recyclerView.setAdapter(mAdapter);
    mAdapter.addHeadLayout(R.layout.item_head);
    mAdapter.addFootLayout(R.layout.item_foot);
    mAdapter.addFootLayout(R.layout.item_foot2);
    List<ImageCard> data = new ArrayList<>();
    for (int i = 0; i < mTitles.length; i++) {
        ImageCard card = new ImageCard(mImageResId[i], mTitles[i]);
        data.add(card);
    }
    mAdapter.setData(data);
    final SwipeRefreshLayout refresh = (SwipeRefreshLayout) findViewById(R.id.refresh);
    refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            refresh();
            refresh.setRefreshing(false);
        }
    });
    findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            refresh();
        }
    });
}
Also used : HeadAndFootAdapter(xyz.zpayh.myadapter.adapter.HeadAndFootAdapter) ArrayList(java.util.ArrayList) ImageCard(xyz.zpayh.myadapter.data.ImageCard) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ArrayList (java.util.ArrayList)1 HeadAndFootAdapter (xyz.zpayh.myadapter.adapter.HeadAndFootAdapter)1 ImageCard (xyz.zpayh.myadapter.data.ImageCard)1