use of com.yanzhenjie.swiperecyclerview.adapter.MainItemAdapter in project SwipeRecyclerView by yanzhenjie.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, LinearLayoutManager.VERTICAL));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(10, 10, 10, 15);
}
});
List<String> titles = Arrays.asList(getResources().getStringArray(R.array.main_item));
List<String> descriptions = Arrays.asList(getResources().getStringArray(R.array.main_item_des));
MainItemAdapter mainItemAdapter = new MainItemAdapter(titles, descriptions);
mainItemAdapter.setOnItemClickListener(this);
recyclerView.setAdapter(mainItemAdapter);
}
Aggregations