Error in Layout, RecyclerView, SQLite DataBase Handler

Issue

I am trying to build a HAPPY PLACE App But I am facing this error.
I want to show image, title and description in my recycle view.
This is what I aim to do

Aim Image

But when I am trying to do the same thing I am getting the image but The title and description show some XML text. I don’t know what’s happening .This is what I am getting 👇

enter image description here

The text is somewhat similar to the code in the Layout file activity_add_happpy_place.xml :

<androidx.appcompat.widget.AppCompatEditText
                android:id="@+id/etTitleAddHappyPlaces"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Title"
                android:padding="20dp"
                android:layout_marginBottom="10dp"
                android:textCursorDrawable="@null"
                />

These are probable files in which the error is ig
activity_add_happpy_place.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="match_parent"
    tools:context=".activities.AddHappyPlaceActivity">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbarAddHappyPlace"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:theme="@style/customToolBarStyle"
        android:background="@color/prussian_blue"
        />

    <ScrollView
        android:id="@+id/scrollViewAddHappyPlaces"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/toolbarAddHappyPlace"
        android:layout_margin="12dp"
        android:fillViewport="true"

        >
        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/til_title"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                app:boxStrokeColor="@color/burly_wood"
                app:hintTextColor="@color/prussian_blue"

                >

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/etTitleAddHappyPlaces"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Title"
                    android:padding="20dp"
                    android:layout_marginBottom="10dp"
                    android:textCursorDrawable="@null"
                    />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/til_description"
                app:layout_constraintTop_toBottomOf="@id/til_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                app:boxStrokeColor="@color/burly_wood"
                app:hintTextColor="@color/prussian_blue"
                >

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/etDescriptionAddHappyPlaces"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Description"
                    android:layout_marginBottom="10dp"
                    android:textCursorDrawable="@null"
                    android:padding="20dp" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/til_date"
                app:layout_constraintTop_toBottomOf="@id/til_description"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                app:boxStrokeColor="@color/burly_wood"
                app:hintTextColor="@color/prussian_blue"
                >

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/etDateAddHappyPlaces"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Date"
                    android:layout_marginBottom="10dp"
                    android:textCursorDrawable="@null"
                    android:focusable="false"
                    android:focusableInTouchMode="false"
                    android:padding="20dp" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/til_location"
                app:layout_constraintTop_toBottomOf="@id/til_date"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                app:boxStrokeColor="@color/burly_wood"
                app:hintTextColor="@color/prussian_blue"
                >

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/etLocationAddHappyPlaces"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Location"
                    android:textCursorDrawable="@null"
                    android:padding="20dp" />
            </com.google.android.material.textfield.TextInputLayout>

            <LinearLayout
                android:id="@+id/llAddImage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toBottomOf="@id/til_location"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_marginTop="70dp"
                >

                <androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/ibAddHappyPlaces"
                    android:layout_width="wrap_content"
                    android:layout_height="130dp"
                    android:layout_weight="2"
                    android:src="@drawable/ic_baseline_image_24"
                    android:background="@drawable/yellow_border"
                    android:scaleType="fitCenter"
                    />
                <TextView
                    android:id="@+id/tvAddImageAddHappyPlaces"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.5"
                    android:text="ADD IMAGE"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:textSize="20dp"
                    android:textColor="@color/copper_orange"
                    />

            </LinearLayout>

            <Button
                android:id="@+id/saveBtnAddHappyPlaces"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toBottomOf="@id/llAddImage"
                android:textColor="@color/white"
                android:text="SAVE"
                android:layout_marginTop="60dp"
                android:textSize="20dp"
                android:backgroundTint="@color/prussian_blue"
                />
        </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

happy_places_item_list:

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

    <androidx.cardview.widget.CardView
        android:id="@+id/cvItemList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        app:cardUseCompatPadding="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:cardCornerRadius="3dp"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="center_horizontal"
            android:padding="10dp"

            >

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/ivCircularImage"
                android:layout_width="70dp"
                android:layout_height="70dp"
                android:src="@drawable/ic_baseline_image_24"
                app:civ_border_color="@color/prussian_blue"

                />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="70dp"
                android:layout_gravity="center"
                android:gravity="center"
                android:orientation="vertical"
                >
                <TextView
                    android:id="@+id/tvItemTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    tools:text = "Name"
                    android:textStyle="bold"
                    />

                <TextView
                    android:id="@+id/tvItemDescription"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    tools:text="description"
                    />
            </LinearLayout>

        </LinearLayout>

    </androidx.cardview.widget.CardView>

</androidx.constraintlayout.widget.ConstraintLayout>

This is the link to all my Activities, Database and adapter files.

Solution

change etTitleAddHappyPlaces.toString() to etTitleAddHappyPlaces.text.toString() and etDescriptionAddHappyPlaces.toString() to etDescriptionAddHappyPlaces.text.toString() in the AddHappyPlaceActivity.kt file

Answered By – Amandeep Singh

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published