-1

我希望你能帮助我。我想使用expandablerecyclerview,但我不需要扩展其他元素的列表,比如lib说

库示例

在此处输入图像描述 我只需要该项目展开并显示回收站内该项目的更多信息

4

1 回答 1

0

您可以使用高级 recyclerview 的可扩展未来

public class ExpandableWithHeaderFooterExampleActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_demo_minimal);

        OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {
            @Override
            public void onItemClicked(String message) {
                View container = findViewById(R.id.container);
                Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
            }
        };

        RecyclerView recyclerView = findViewById(R.id.recycler_view);

        // Setup expandable feature and RecyclerView
        RecyclerViewExpandableItemManager expMgr = new RecyclerViewExpandableItemManager(null);

        // Create wrapped adapter:  MyItemAdapter -> expMgr.createWrappedAdapter -> MyHeaderFooterAdapter
        RecyclerView.Adapter adapter;
        adapter = new SimpleDemoExpandableItemAdapter(expMgr, clickListener);
        adapter = expMgr.createWrappedAdapter(adapter);
        adapter = new DemoHeaderFooterAdapter(adapter, clickListener);

        recyclerView.setAdapter(adapter);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        // NOTE: need to disable change animations to ripple effect work properly
        ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);

        expMgr.attachRecyclerView(recyclerView);
    }
}
于 2018-03-21T06:27:42.077 回答