Search in sources :

Example 1 with GalleryRecyclerAdapter

use of com.chinaztt.fda.adapter.GalleryRecyclerAdapter 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();
        }
    });
}
Also used : CustomLinearLayoutManager(com.chinaztt.fda.widget.CustomLinearLayoutManager) GalleryRecyclerAdapter(com.chinaztt.fda.adapter.GalleryRecyclerAdapter) TestDecoration(com.chinaztt.fda.widget.TestDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CustomLinearLayoutManager(com.chinaztt.fda.widget.CustomLinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1 GalleryRecyclerAdapter (com.chinaztt.fda.adapter.GalleryRecyclerAdapter)1 CustomLinearLayoutManager (com.chinaztt.fda.widget.CustomLinearLayoutManager)1 TestDecoration (com.chinaztt.fda.widget.TestDecoration)1