使我的自定义视图更新编辑器中的文本字段

因此,即时通讯目前正在处理自定义卡片视图,我的目标非常简单。我想将文本字段更新为在自定义卡片视图xml中设置的字符串。


但是,经过数小时的尝试,以某种方式我无法使它正常工作。有时编辑器不会使用自定义卡片视图加载我的xml ...有时它会给我一个非常长的错误消息...有时它会保持黑色...


因此,我有以下xml文件:


<LinearLayout 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:id="@+id/CallEntry_Holder"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:tag="0">


<com.test.larsmatthaus.projectnurser.customs.Custom_CardView


    android:id="@+id/Call_Entry"

    android:layout_width="match_parent"

    android:layout_height="50dp"

    app:cardBackgroundColor="@color/colorCardBackgroundR"

    app:cardCornerRadius="5dp"

    app:personName="test"

    app:room="100"

    app:ward="test"

    tools:layout_editor_absoluteX="1024dp">


    <android.support.constraint.ConstraintLayout

        android:layout_width="match_parent"

        android:layout_height="50dp">


        <TextView

            android:id="@+id/WardName"

            android:layout_width="0dp"

            android:layout_height="0dp"

            android:layout_marginBottom="10dp"

            android:layout_marginEnd="200dp"

            android:layout_marginLeft="200dp"

            android:layout_marginRight="200dp"

            android:layout_marginStart="200dp"

            android:layout_marginTop="10dp"


它仅包含一个卡视图条目。

我想将TextView“ wardName”更新为我在xml文件中设置的属性值...

但是以某种方式,一旦我加载它,编辑器视图就会崩溃...由于自定义CardView类...没有真正的错误日志...

我收到的唯一消息是:渲染布局时预览超时。当其中一个自定义视图中存在无限循环或无限递归时,通常会发生这种情况

我忘了什么?我还能尝试什么修改编辑器的textview?


手掌心
浏览 144回答 1
1回答

鸿蒙传说

好吧,这很容易...只是添加了一个新的布局活动,该活动将在按下CardView时膨胀。我只是复制CardView元素并将其放置在膨胀视图内=>问题已解决:)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java