use of com.chinaztt.fda.widget.TestDecoration in project FastDev4Android by jiangqqlmj.
the class RecyclerGalleryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recycler_gallery_layout);
top_bar_linear_back = (LinearLayout) this.findViewById(R.id.top_bar_linear_back);
btn_add = (Button) this.findViewById(R.id.btn_add);
btn_delete = (Button) this.findViewById(R.id.btn_delete);
top_bar_linear_back.setOnClickListener(new CustomOnClickListener());
btn_add.setOnClickListener(new CustomOnClickListener());
btn_delete.setOnClickListener(new CustomOnClickListener());
top_bar_title = (TextView) this.findViewById(R.id.top_bar_title);
top_bar_title.setText("RecyclerView打造Gallery效果");
//初始化RecyclerView控件
gallery_recycler = (RecyclerView) this.findViewById(R.id.gallery_recycler);
//固定高度
gallery_recycler.setHasFixedSize(true);
//创建布局管理器
LinearLayoutManager linearLayoutManager = new CustomLinearLayoutManager(this);
//设置横向
linearLayoutManager.setOrientation(OrientationHelper.HORIZONTAL);
//设置布局管理器
gallery_recycler.setLayoutManager(linearLayoutManager);
//设置分割线
gallery_recycler.addItemDecoration(new TestDecoration(this));
//设置动画
gallery_recycler.setItemAnimator(new DefaultItemAnimator());
//创建适配器
adapter = new GalleryRecyclerAdapter(this);
//绑定适配器
gallery_recycler.setAdapter(adapter);
adapter.setOnRecyclerViewItemClickListener(new GalleryRecyclerAdapter.OnRecyclerViewItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Toast.makeText(RecyclerGalleryActivity.this, "您点击的Item的索引为:" + position, Toast.LENGTH_SHORT).show();
}
});
}
Aggregations