当前位置: 首页>>代码示例>>Java>>正文


Java RVHItemDividerDecoration类代码示例

本文整理汇总了Java中github.nisrulz.recyclerviewhelper.RVHItemDividerDecoration的典型用法代码示例。如果您正苦于以下问题:Java RVHItemDividerDecoration类的具体用法?Java RVHItemDividerDecoration怎么用?Java RVHItemDividerDecoration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RVHItemDividerDecoration类属于github.nisrulz.recyclerviewhelper包,在下文中一共展示了RVHItemDividerDecoration类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import github.nisrulz.recyclerviewhelper.RVHItemDividerDecoration; //导入依赖的package包/类
private void init() {
    dm = new DBManager(this);
    dm.readFromDB(noteDataList);
    myrecyclerview = (RecyclerView) findViewById(R.id.rv_list);
    Intent searchIntent = getIntent();
    if (Intent.ACTION_SEARCH.equals(searchIntent.getAction()))
        query = searchIntent.getStringExtra(SearchManager.QUERY);
    myrecyclerview.hasFixedSize();
    myrecyclerview.setLayoutManager(new LinearLayoutManager(this));

    for (int i = 0; i < noteDataList.size(); i++) {
        if (noteDataList.get(i).getTitle().toLowerCase().contains(query.toLowerCase()))
            temp.add(noteDataList.get(i));
    }
    adapter = new RecyclerViewAdapter(this, temp);
    myrecyclerview.setAdapter(adapter);

    // Setup onItemTouchHandler
    ItemTouchHelper.Callback callback = new RVHItemTouchHelperCallback(adapter, true, true, true);
    ItemTouchHelper helper = new ItemTouchHelper(callback);
    helper.attachToRecyclerView(myrecyclerview);

    // Set the divider
    myrecyclerview.addItemDecoration(
            new RVHItemDividerDecoration(this, LinearLayoutManager.VERTICAL));

    // Set On Click
    myrecyclerview.addOnItemTouchListener(
            new RVHItemClickListener(this, new RVHItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {
                    int noteId = noteDataList.get(position).getId();
                    Intent intent = new Intent(SearchActivity.this, EditNoteActivity.class);
                    intent.putExtra("id", noteId);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                    finish();
                }
            }));
}
 
开发者ID:chatRG,项目名称:NoteNow,代码行数:41,代码来源:SearchActivity.java


注:本文中的github.nisrulz.recyclerviewhelper.RVHItemDividerDecoration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。