2016-12-06 6 views
0

問題:次のクラスをインスタンス化できませんでした:android.support.v7.widget.AppCompatImageView

次のクラスをインスタンス化できませんでした:ここandroid.support.v7.widget.AppCompatImageView

ですIDEが提供するヒント。

 Rendering Problems The following classes could not be instantiated: 
- android.support.v7.widget.AppCompatImageView (Open Class, Show Exception, Clear Cache) 

Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. 


Tip: Try to refresh the layout. 

はここにここに私のfragment_comment.xml

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

    <RelativeLayout 
     android:id="@+id/content_rl" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <ImageView 
      android:id="@+id/comment_large_head" 
      android:layout_width="28dp" 
      android:layout_height="28dp" 
      app:srcCompat="@drawable/ic_comment_head_large" /> 

     <TextView 
      android:id="@+id/name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="4dp" 
      android:layout_toRightOf="@id/comment_large_head" 
      android:text="Romain Beaumont" /> 

     <TextView 
      android:id="@+id/comment_time" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@id/name" 
      android:layout_below="@id/name" 
      android:text="7h" /> 

     <TextView 
      android:id="@+id/content" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignLeft="@id/name" 
      android:layout_below="@+id/comment_time" 
      android:text="The previous deal was rejected by the Colombian people in a popular vote on 2 October.The previous deal was" /> 

     <ImageView 
      android:id="@+id/comment_like_iv" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      app:srcCompat="@drawable/ic_comment_unlike" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_marginRight="5dp" 
      android:layout_toLeftOf="@id/comment_like_iv" 
      android:text="32" /> 
    </RelativeLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/replies" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="32dp" 
     android:layout_marginRight="5dp"/> 
</LinearLayout> 

ここで、トレース・スタックである私のfragment_comment_list.xml

<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:id="@+id/main_content" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:weightSum="1"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginStart="10dp" 
      android:layout_marginTop="18dp" 
      android:text="@string/title_best_comments" 
      android:textColor="@color/dark_primary" 
      android:textSize="14sp" /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/best_comments_rv" 
      android:name="com.opera.android.news.comment.CommentFragment" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="15dp" 
      app:layoutManager="LinearLayoutManager" 
      tools:context="com.opera.android.news.comment.CommentFragment" 
      tools:listitem="@layout/fragment_comment" /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginStart="10dp" 
      android:layout_marginTop="18dp" 
      android:text="@string/title_latest_comments" 
      android:textColor="@color/dark_primary" 
      android:textSize="14sp" /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/latest_comments_rv" 
      android:name="com.opera.android.news.comment.CommentFragment" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      app:layoutManager="LinearLayoutManager" 
      tools:context="com.opera.android.news.comment.CommentFragment" 
      tools:listitem="@layout/fragment_comment" /> 

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

です。

例外 android.content.res.Resources_Delegate.getValue(Resources_Delegate.java:747)における詳細java.lang.NullPointerExceptionがandroid.content.res.Resources.getValue(Resources.java:1286)で で android.support.v7.widget.AppCompatDrawableManager.createDrawableIfNeeded(AppCompatDrawableManager.java:234) でandroid.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197) android.support.v7.widgetで.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188) at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100) android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:54) android.support.v7で で 。 widget.AppCompatImageView。(AppCompatImageView.java:66) android.support.v7.widget.AppCompatImageViewた。java.lang.reflect.Constructor.newInstanceで(AppCompatImageView.java:56) (Constructor.java:423) android.view.LayoutInflater.onCreateView(LayoutInflater.java:717) で でandroid.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785) android.view.LayoutInflater.creでateViewFromTag(LayoutInflater.java:727) でandroid.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858) でandroid.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)android.view.LayoutInflaterで 。 でrInflate android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)で android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)で(LayoutInflater.java:834) android.view.LayoutInflater_Delegate .rInflate(LayoutInflater_Delegate.java:70) android.view.LayoutInflater.rInflate(LayoutInflater.java:834) でandroid.view.LayoutInflater.inflate(LayoutInflater.java:426)でandroid.view.LayoutInflater.inflateで android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) (LayoutInflater.java:518)でcom.android.layoutlib.bridge.android.support.Adapter.onCreateViewHolder at android.support.v7.widget.RecyclerView $ Adapter.createViewHolder(RecyclerView.java:6078)at android.support.v7.widget.RecyclerView $ Recycler .getViewForPosition(RecyclerView。Javaの:5248) android.support.v7.widget.LinearLayoutManager $ LayoutState.nextで android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.java:5158) (LinearLayoutManager.java:2061)で でandroid.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1445) でandroid.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1408) android.support.v7で.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:580) ( )android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3379) でandroid.support.v7.widget.RecyclerView.onMeasure_Original(RecyclerView.java:2906) でandroid.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:-1)android.view.Viewで 。 android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) でandroid.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) 小節(View.java:19731) android.widget.LinearLayoutました。でandroid.view.View.measure(View.java:19731)を android.support.v4.widgetにして、measureVertical(LinearLayout.java:758) をandroid.widget.LinearLayout.onMeasure(LinearLayout.java:640)に設定します。 NestedScrollVi アンドロイドでandroid.support.v4.widget.NestedScrollView.onMeasure_Original(NestedScrollView.java:482)でandroid.widget.FrameLayout.onMeasure(FrameLayout.java:185) でew.measureChildWithMargins(NestedScrollView.java:1420) .support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:-1) android.view.View.measure(View.java:19731)at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) android.widget.RelativeLayout.measureChildHorizo​​ntal(RelativeLayout.java:715)で android.view.View.measure(View.java:19731)でandroid.widget.FrameLayout.onMeasure(FrameLayout.java:185) ででandroid.widget.RelativeLayout.onMeasure(Rela tiveLayout.java:461) android.view.View.measure(View.java:19731)スタックを にコピーしますclipboard @ drawable/ic_comment_unlikeというリソースを解決できませんでした(23 同様のエラーは表示されません) @drawable /描画可能(詳細)にic_comment_unlike(示されていない21と同様の エラー)

答えて

0

あなたはImageViewのを初期化していないように思えるの。 またはjavaコードを教えてください。

+0

今、このエラーが発生しています。ランタイムエラーではなく、レイアウトエディタにアンドロイドスタジオのエラーメッセージが表示されます。 – Pablo

関連する問題