Autore Topic: problema visualizzazione elenco prodotti  (Letto 81 volte)

Offline newbie2016

  • Utente junior
  • **
  • Post: 79
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Cubot X9
  • Sistema operativo:
    Windows 7
problema visualizzazione elenco prodotti
« il: 27 Ottobre 2016, 12:24:26 CEST »
0
Salve, quando apro la schermata dei prodotti l'app si crasha. Di seguito il logCat

Citazione
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.appdemo, PID: 14013
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.appdemo/com.example.appdemo.product}: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.CollapsingToolbarLayout
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
                      at android.app.ActivityThread.access$800(ActivityThread.java:151)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
                      at android.os.Handler.dispatchMessage(Handler.java:110)
                      at android.os.Looper.loop(Looper.java:193)
                      at android.app.ActivityThread.main(ActivityThread.java:5333)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
                      at dalvik.system.NativeStart.main(Native Method)
                   Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.CollapsingToolbarLayout
                      at android.view.LayoutInflater.createView(LayoutInflater.java:620)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                      at com.example.appdemo.product.onCreate(product.java:47)
                      at android.app.Activity.performCreate(Activity.java:5343)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
                      at android.app.ActivityThread.access$800(ActivityThread.java:151)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
                      at android.os.Handler.dispatchMessage(Handler.java:110)
                      at android.os.Looper.loop(Looper.java:193)
                      at android.app.ActivityThread.main(ActivityThread.java:5333)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
                      at dalvik.system.NativeStart.main(Native Method)
                   Caused by: java.lang.reflect.InvocationTargetException
                      at java.lang.reflect.Constructor.constructNative(Native Method)
                      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                      at android.view.LayoutInflater.createView(LayoutInflater.java:594)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                      at com.example.appdemo.product.onCreate(product.java:47)
                      at android.app.Activity.performCreate(Activity.java:5343)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
                      at android.app.ActivityThread.access$800(ActivityThread.java:151)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
                      at android.os.Handler.dispatchMessage(Handler.java:110)
                      at android.os.Looper.loop(Looper.java:193)
                      at android.app.ActivityThread.main(ActivityThread.java:5333)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
                      at dalvik.system.NativeStart.main(Native Method)
                   Caused by: java.lang.NoSuchMethodError: android.support.v4.graphics.drawable.DrawableCompat.setLayoutDirection
                      at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
                      at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:197)
                      at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:132)
                      at java.lang.reflect.Constructor.constructNative(Native Method)
                      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                      at android.view.LayoutInflater.createView(LayoutInflater.java:594)
                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                      at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                      at com.example.appdemo.product.onCreate(product.java:47)
                      at android.app.Activity.performCreate(Activity.java:5343)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
                      at android.app.ActivityThread.access$800(ActivityThread.java:151)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
                      at android.os.Handler.dispatchMessage(Handler.java:110)
                      at android.os.Looper.loop(Looper.java:193)
                      at android.app.ActivityThread.main(ActivityThread.java:5333)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
                      at dalvik.system.NativeStart.main(Native Method)

la riga che da errore è:
Codice (Java): [Seleziona]
setContentView(R.layout.product);qui di seguito la composizione della schermata:
product.xml
Codice (XML): [Seleziona]
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:fitsSystemWindows="true"
   tools:openDrawer="start">

    <include
       layout="@layout/app_bar_main8"
       android:layout_width="match_parent"
       android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
       android:id="@+id/nav_view"
       android:layout_width="wrap_content"
       android:layout_height="match_parent"
       android:layout_gravity="start"
       android:fitsSystemWindows="true"
       app:headerLayout="@layout/nav_header_main"
       app:menu="@menu/activity_main_drawer" />


</android.support.v4.widget.DrawerLayout>

include app_bar_main8.xml
Codice (XML): [Seleziona]
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
android:fitsSystemWindows="true"
tools:context="com.example.appdemo.product">

<android.support.design.widget.AppBarLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:theme="@style/AppTheme.AppBarOverlay"
   android:isScrollContainer="true">

    <android.support.design.widget.CollapsingToolbarLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content">



        <ImageView
           android:id="@+id/backdrop"
           android:layout_width="match_parent"
           android:layout_height="200dp"
           android:scaleType="centerCrop"
           android:fitsSystemWindows="true"
           android:src="@drawable/ferro"
           app:layout_collapseMode="none"
           android:contentDescription=""
           tools:ignore="ContentDescription"
           android:layout_marginTop="0dp"
           android:elevation="0dp" />

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

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

    <android.support.v4.widget.NestedScrollView
   android:layout_width="match_parent"
   android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
           android:id="@+id/toolbar"
           android:layout_width="match_parent"
           android:layout_height="?attr/actionBarSize"
           app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
           app:layout_collapseMode="pin"
           app:titleTextAppearance="@android:style/TextAppearance"
           android:background="@color/answer_text" />

</android.support.v4.widget.NestedScrollView>

    <include layout="@layout/activity_main_in_8" />
</android.support.design.widget.CoordinatorLayout>

activity_main_in_8.xml
Codice (XML): [Seleziona]
<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:layout_width="match_parent"
   android:layout_height="match_parent"
   android:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   tools:context="com.example.appdemo.product"
   tools:showIn="@layout/app_bar_main8">


    <ListView
       android:layout_width="wrap_content"
       android:layout_height="match_parent"
       android:id="@+id/listViewProduct" />
</LinearLayout>

Come posso risolverlo?

Grazie

Post unito: [time]27 Ottobre 2016, 15:39:01 CEST[/time]
Niente mi da sempre lo stesso errore

Post unito: [time]27 Ottobre 2016, 16:12:40 CEST[/time]
se elimino il android.support.design.widget.CollapsingToolbarLayout

mi non mi da problemi.

Post unito: 27 Ottobre 2016, 18:27:24 CEST
Il problema è qui:
Codice (Java): [Seleziona]
<android.support.design.widget.CollapsingToolbarLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content">



        <ImageView
           android:id="@+id/backdrop"
           android:layout_width="match_parent"
           android:layout_height="200dp"
           android:scaleType="centerCrop"
           android:fitsSystemWindows="true"
           android:src="@drawable/ferro"
           app:layout_collapseMode="none"
           android:contentDescription=""
           tools:ignore="ContentDescription"
           android:layout_marginTop="0dp"
           android:elevation="0dp" />

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

la sintassi è corretta?
Devo aggiungere qualcosa nel file product.java?

Grazie
« Ultima modifica: 27 Ottobre 2016, 18:27:24 CEST da newbie2016, Reason: Merged DoublePost »