【问题标题】:Multiple ListViews in RecyclerViewRecyclerView 中的多个 ListView
【发布时间】:2020-02-24 15:29:20
【问题描述】:

我想在我的每个 RecyclerView 项目下方有多个 listViews。最初,每个都将被隐藏,但当用户点击通话记录项目时,该项目将展开,显示下面的详细信息,如下所示。我有一个 List 变量,它包含所有可用的日志详细信息,我将其传递到我的 ListView:

mLogsList.setAdapter(new HistoryLogAdapter(
     view.getContext(), R.layout.history_detail_cell, mLogs));

当我打印出 mLogs 时,它会显示所有可用的日志详细信息,但是当我将它传递到 RecyclerView 项时,它总是只显示所有条目的第一个日志。

关于我做错了什么有什么想法吗?

进一步的背景:

List<CallLog> mLogs = Arrays.asList(LinphoneManager.getCore().getCallLogs());

            CallLog log = mLogs.get(getAdapterPosition());
            Address address = log.getFromAddress();

            String mSipUri = (address != null) ? address.asString() : "";

            if (mSipUri != null) {
                address = Factory.instance().createAddress(mSipUri);

                Core core = LinphoneManager.getCore();
                if (address != null && core != null) {
                    address.clean();
                    ProxyConfig proxyConfig = core.getDefaultProxyConfig();
                    CallLog[] logs;
                    if (proxyConfig != null) {
                        logs = core.getCallHistory(address, proxyConfig.getIdentityAddress());
                    } else {
                        logs = core.getCallHistoryForAddress(address);
                    }

                    mLogsList.setAdapter(
                            new HistoryLogAdapter(
                                    view.getContext(), R.layout.history_detail_cell, mLogs));
                    mLogsList.setVerticalScrollBarEnabled(false);
                    mLogsList.setEnabled(false);
                }

【问题讨论】:

    标签: android listview adapter


    【解决方案1】:

    我非常感谢您的努力,但在我看来,您可以将您的 listItem 视为一个部分。 可扩展的 RecyclerView 有一个非常好的和方便的库。你的案子很受欢迎,我个人以前也遇到过。 所以我推荐使用this library 它会为你提供一个分段RecyclerView 的解决方案。更具体地说,您可以查看 this example 以获取可扩展的分段 RecyclerView。

    我希望这会有所帮助。

    【讨论】:

    • 谢谢你 Mustafa,我去看看!
    猜你喜欢
    • 2018-01-27
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    • 2019-08-26
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多