Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TableLayout Crashing application on android Lollipop [duplicate]

I am using TableLayout in one of my activity layout. but when I am trying to run same activity on the Lollipop it crashes.

It works perfectly on Marshmallow and Nougat.

When I tried to run it after removing TableLayout(ONLY) it worked fine in Lollipop also.

I tried removing all java code on the activity, its having same problem.

My Crash Report

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.sovereignconsult.region.viand, PID: 19434 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference at android.widget.LinearLayout.forceUniformHeight(LinearLayout.java:1380) at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1368) at android.widget.TableRow.onMeasure(TableRow.java:114) at android.view.View.measure(View.java:17826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5653) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.TableLayout.measureChildBeforeLayout(TableLayout.java:464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.TableLayout.measureVertical(TableLayout.java:476) at android.widget.TableLayout.onMeasure(TableLayout.java:439) at android.view.View.measure(View.java:17826) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android.view.View.measure(View.java:17826) at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1269) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.widget.ScrollView.onMeasure(ScrollView.java:338) at android.view.View.measure(View.java:17826) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464) at android.view.View.measure(View.java:17826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5653) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:17826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5653) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5653) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.view.View.measure(View.java:17826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5653) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5653) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2748) at android.view.View.measure(View.java:17826) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2030) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1174) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1395) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1062) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5873) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5536) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1397) at com.android.internal.

Layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/tools"
    xmlns:design="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<include android:id="@+id/toolbar"
    layout="@layout/top_bar"/>
<ScrollView
    android:id="@+id/productscrollview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="UselessParent"
    android:layout_below="@id/toolbar">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp">

        <TextView
            android:id="@+id/offeringNmae"
            android:textStyle="normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="20dp"
            android:layout_marginBottom="20dp"
            android:textSize="23sp"
            android:textColor="@color/lildark"
            android:text="Name of Offering" />
        <TextView
            android:id="@+id/terms"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/orderTerms"
            android:layout_below="@id/offeringNmae"
            android:textSize="10sp"
            android:layout_marginBottom="5dp"/>



        <TableLayout
            android:id="@+id/orderDetails"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="1"
            android:background="@drawable/cell_shape"
            android:layout_below="@id/terms"
            android:layout_marginBottom="10dp">
            <TableRow
                android:paddingTop="10dp"
                android:paddingBottom="10dp">
                <TextView
                    android:layout_column="1"
                    android:text="Details"
                    android:layout_marginStart="15dp"
                    android:textStyle="bold"/>
            </TableRow>
            <View
                android:layout_height="1dp"
                android:background="@color/lightGray"/>
            <TableRow
                android:paddingTop="10dp"
                android:paddingBottom="10dp">
                <TextView
                    android:id="@+id/orderName"
                    android:layout_column="1"
                    android:padding="3dip"
                    android:layout_marginStart="15dp"/>
                <TextView
                    android:id="@+id/quantity"
                    android:layout_column="2"
                    android:gravity="end"
                    android:padding="3dip"/>
                <TextView
                    android:id="@+id/price"
                    android:layout_column="3"
                    android:gravity="end"
                    android:padding="3dip"
                    android:layout_marginEnd="15dp"/>
            </TableRow>

            <View
                android:layout_height="1dp"
                android:background="@color/lightGray"/>
            <TableRow
                android:paddingTop="10dp"
                android:paddingBottom="10dp">
                <TextView
                    android:layout_column="1"
                    android:padding="3dip"
                    android:text="Total Amount"
                    android:layout_marginStart="15dp"/>
                <TextView
                    android:layout_column="3"
                    android:id="@+id/totalamount"
                    android:gravity="right"
                    android:padding="3dip"
                    android:layout_marginEnd="15dp"/>
            </TableRow>

        </TableLayout>
        <TableLayout
            android:id="@+id/orderAddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="1"
            android:background="@drawable/cell_shape"
            android:layout_below="@id/orderDetails"
            android:layout_marginBottom="10dp">
            <TableRow
                android:paddingTop="10dp"
                android:paddingBottom="10dp">
                <TextView
                    android:layout_column="1"
                    android:padding="3dip"
                    android:text="Pickup Address"
                    android:layout_marginStart="15dp"
                    android:textStyle="bold"/>

            </TableRow>
            <View
                android:layout_height="1dp"
                android:background="@color/lightGray"/>
            <TableRow
                android:paddingTop="10dp"
                android:paddingBottom="10dp">

                <TextView
                    android:layout_column="1"
                    android:id="@+id/address"
                    android:layout_height="fill_parent"
                    android:layout_width="wrap_content"
                    android:layout_marginLeft="15dp"
                    android:layout_marginRight="15dp"/>
            </TableRow>
        </TableLayout>
        <TableLayout
            android:id="@+id/chefNote"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="1"
            android:background="@drawable/cell_shape"
            android:layout_below="@id/orderAddress">
            <TableRow
                android:paddingTop="10dp"
                android:paddingBottom="10dp">
                <TextView
                    android:layout_column="1"
                    android:padding="3dip"
                    android:text="Note For Chef"
                    android:layout_marginStart="15dp"
                    android:textStyle="bold"/>

            </TableRow>
            <View
                android:layout_height="1dp"
                android:background="@color/lightGray"/>
            <TableRow
                android:paddingTop="10dp"
                android:paddingBottom="10dp">

                <TextView
                    android:layout_column="1"
                    android:id="@+id/ChefNote"
                    android:layout_height="fill_parent"
                    android:layout_width="wrap_content"
                    android:layout_marginLeft="15dp"
                    android:layout_marginRight="15dp"/>
            </TableRow>
        </TableLayout>


    </RelativeLayout>
</ScrollView>
<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_height="60dp"
    android:layout_width="match_parent"
    android:layout_alignParentBottom="true"
    app:itemBackground="@color/defaultText"
    android:background="@color/defaultText"
    android:paddingRight="10dp"
    android:paddingLeft="10dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:gravity="center_horizontal"
        android:weightSum="2">

        <Button
            android:id="@+id/bookbottom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/PayNow"
            android:layout_weight="1"
            android:background="@drawable/buttonstyledefaultcolor"
            android:layout_gravity="center"
            android:textColor="@color/colorPrimary"
            android:padding="0dp"
            android:layout_marginTop="2dp"/>
    </LinearLayout>


</android.support.design.widget.BottomNavigationView>

public class order_verification_activity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_verification);
    }
}
like image 399
parish Avatar asked Oct 18 '22 02:10

parish


1 Answers

remove layout_width and layout_height or make layout_height="wrap_content" in textview inside table row

 <TableRow
            android:paddingTop="10dp"
            android:paddingBottom="10dp">

            <TextView
                android:layout_column="1"
                android:id="@+id/address"
                android:layout_height="fill_parent"
                android:layout_width="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"/>
        </TableRow>
like image 161
Bek Avatar answered Oct 21 '22 00:10

Bek