Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableEntry cannot use textLayout interface #483

Open
mutour opened this issue Aug 16, 2024 · 0 comments
Open

TableEntry cannot use textLayout interface #483

mutour opened this issue Aug 16, 2024 · 0 comments

Comments

@mutour
Copy link

mutour commented Aug 16, 2024

  • Markwon version: 4.6.2

Use the following method to load Table, and the error The specified child already has a parent. You must call removeView() is reported. After checking the source code, it is found that the source code inserts the TextView inside the ConstraintLayout into the TableRow through addView.

markwonAdapter = MarkwonAdapter.builder(simpleEntry)
            .include(FencedCodeBlock::class.java, FencedCodeBlockEntry(coroutineScope))
            .include(TableBlock::class.java, TableEntry.create { builder ->
                builder
                    .tableLayout(R.layout.markwon_table_block, R.id.table_layout)
                    .textLayout(R.layout.layout_markdown_entry, R.id.text_view)
            })
            .build()

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:5259)
at android.view.ViewGroup.addView(ViewGroup.java:5090)
at android.view.ViewGroup.addView(ViewGroup.java:5030)
at android.view.ViewGroup.addView(ViewGroup.java:5003)
at io.noties.markwon.recycler.table.TableEntry.ensureTextView(TableEntry.java:325)
at io.noties.markwon.recycler.table.TableEntry.bindHolder(TableEntry.java:174)
at io.noties.markwon.recycler.table.TableEntry.bindHolder(TableEntry.java:36)
at io.noties.markwon.recycler.MarkwonAdapterImpl.onBindViewHolder(MarkwonAdapterImpl.java:85)
at io.noties.markwon.recycler.MarkwonAdapterImpl.onBindViewHolder(MarkwonAdapterImpl.java:17)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7747)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7847)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6646)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6917)

layout_markdown_entry.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/text_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant