package com.lcp.arecyclerview;

import android.app.Activity;
import android.os.Bundle;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lcp.arecyclerview.adapter.SimpleRecyclerViewAdapter;

import java.util.ArrayList;

/**
 * Created by Aislli on 2016/3/3.
 */
public class SimpleRecyclerViewActivity extends Activity {

    private RecyclerView recyclerView;
    private LinearLayoutManager linearLayoutManager;
    private ArrayList<String> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_simple);
        initView();
        initData();
    }

    private void initView() {
        recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
    }

    private void initData() {
        list = new ArrayList<>();
        for (int i = 0; i < 60; i++) {
            list.add("item:" + i);
        }
        SimpleRecyclerViewAdapter simpleRecyclerViewAdapter = new SimpleRecyclerViewAdapter(this, list);
//        linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager = new GridLayoutManager(this,3);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(simpleRecyclerViewAdapter);
    }
}
