-1

This error comes when I am running the app.

java.lang.RuntimeException: Unable to start activity ComponentInfo : android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.GridLayout

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.ankur.shop.HomeActivity"
    android:background="@drawable/gradient7">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome"
        android:id="@+id/welcomeText"
        android:layout_row="0"
        android:layout_column="0" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/nameText"
        android:layout_row="0"
        android:layout_column="1" />

    <ViewFlipper
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/viewFlipper"
        android:layout_row="1"
        android:layout_column="0"
        android:inAnimation="@color/abc_color_highlight_material"
        android:flipInterval="@integer/abc_config_activityDefaultDur">

        <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/picture1" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/picture2" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/picture3" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/picture4" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/picture5" />

    </ViewFlipper>
</GridLayout>
Ankur
  • 11
  • 6

1 Answers1

0

As the documentation, you must be aware that App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget.

May be your GridView is not allowed where you are trying to use that. A RemoteViews object can support the following layout classes:

  • FrameLayout
  • LinearLayout
  • RelativeLayout
  • GridLayout

See more at here

Solution

  • Try using another layout type in your remote view.
  • You probably using prior than 4.2. which may not support, review that too.
Shree Krishna
  • 8,474
  • 6
  • 40
  • 68