-1

I have list item row, which is perfectly working until I add a view as border I get a NullPointerException. I don't get it. If I comment the view every thing gonna be ok.

    <android.support.v7.widget.CardView
        android:id="@+id/cardView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/custom_bg"
        android:focusable="true"
        card_view:cardElevation="4dp"


        card_view:cardUseCompatPadding="true">

        <LinearLayout
            android:layout_width="match_parent"

            android:layout_height="match_parent"
            android:background="@drawable/custom_bg"
            android:orientation="vertical">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">


                <TextView
                    android:id="@+id/tvUpazilas"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="5dp"
                    android:text="Upazila Name :"
                    android:textColor="#73A7D5"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/tvUpazilaName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="5dp"
                    android:text="Upazila Name"
                    android:textColor="#2F3133" />


            </LinearLayout>

            <view
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#dbe3f1" />

           </LinearLayout>
    </android.support.v7.widget.CardView>


</LinearLayout>

logcat:

     com.primetech.gis E/UncaughtException: android.view.InflateException: Binary XML file line #67: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
Mauker
  • 11,237
  • 7
  • 58
  • 76
Faisal Mohammad
  • 427
  • 1
  • 9
  • 27
  • 2
    You have a lowercase-`v` `` element without a `class` attribute, which is why you get that particular Exception. You want to use uppercase-`V` `` instead. – Mike M. Oct 22 '18 at 13:46
  • 1
    No problem. If I understand what you're asking, lowercase-`v` `` is used with a `class` attribute that specifies which `View` subclass to instantiate for the given tag. It's mainly for custom `View`s. Uppercase-`V` `` is used when you just need a spacer or simple decoration in your layout, like you're using it here. – Mike M. Oct 22 '18 at 14:00
  • 1
    thanks a lot for ur help. – Faisal Mohammad Oct 22 '18 at 14:01

1 Answers1

2

Please replace this

 <view
     android:layout_width="match_parent"
     android:layout_height="1dp"
     android:background="#dbe3f1" />

with this

 <View
     android:layout_width="match_parent"
     android:layout_height="1dp"
     android:background="#dbe3f1" />
Powkachu
  • 2,170
  • 2
  • 26
  • 36