在RecyclerView适配器中输入类<unknown>时出错

时间:2016-12-19 18:03:38

标签: android android-recyclerview

我是android编程的初学者

我从网上获取在线数据并在SD卡中保存图像

在我在recyclerview中展示它们之后。

应用程序在genymotion samsung android 6.0.0中崩溃

那是我的项目xml:

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    card_view:cardCornerRadius="4dp"
    card_view:cardUseCompatPadding="true">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/image_book"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center_horizontal"
                android:adjustViewBounds="true"
                android:padding="10dp"
                android:scaleType="fitXY"
                android:src="@drawable/exam" />

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

                android:paddingLeft="10dp"
                android:paddingRight="10dp">

                <ImageView
                    android:id="@+id/three_dots"
                    android:layout_width="15dp"
                    android:layout_height="wrap_content"

                    android:src="@drawable/dots" />

                <TextView

                    android:id="@+id/name"
                    android:layout_width="match_parent"
                    android:layout_height="40sp"
                    android:text=""
                    android:lineSpacingExtra="-5dp"
                    android:textColor="@color/black" />

            </LinearLayout>

            <View
                android:id="@+id/title22"
                android:layout_width="match_parent"
                android:layout_height="1px"
                android:layout_marginBottom="2dp"
                android:layout_marginTop="2dp"
                android:background="#cfcfcf"
                android:gravity="center" />

            <TextView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingRight="10dp"
                android:paddingTop="3dp"
                android:paddingBottom="3dp"
                android:paddingLeft="10dp"
                android:text="نحو" />




        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true">

            <ImageView
                android:id="@+id/free_tag"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:src="@drawable/free" />

            <ImageView
                android:id="@+id/des_tag"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:src="@drawable/des_tag" />

            <ImageView
                android:id="@+id/music_tag"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:src="@drawable/music_tag" />

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

和我在recycleview适配器中的方法:

    @Override
    public RecyclerViewHolderMain onCreateViewHolder(ViewGroup viewGroup, int viewType) {

        // This method will inflate the custom layout and return as viewholder
        LayoutInflater mInflater = LayoutInflater.from(viewGroup.getContext());

        ViewGroup mainGroup = (ViewGroup) mInflater.inflate(
                R.layout.item_main_row, viewGroup, false);
        RecyclerViewHolderMain listHolder = new RecyclerViewHolderMain(mainGroup);
        return listHolder;

    }

这是我的崩溃日志:

FATAL EXCEPTION: main
  Process: com.rohamweb.hozebook, PID: 6006
  android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class <unknown>
        at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
        at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at com.rohamweb.hozebook.RecyclerViewAdapterMain.onCreateViewHolder(RecyclerViewAdapterMain.java:144)
        at com.rohamweb.hozebook.RecyclerViewAdapterMain.onCreateViewHolder(RecyclerViewAdapterMain.java:22)
        at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6078)
        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5248)
        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5158)
        at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2061)
        at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1445)
        at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1408)
        at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:555)
        at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3379)
        at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2906)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1283)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.widget.ScrollView.onMeasure(ScrollView.java:340)
        at android.view.View.measure(View.java:18788)
        at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1662)
        at android.view.View.measure(View.java:18788)
        at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
        at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:703)
        at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:770)
        at android.view.View.measure(View.java:18788)
        at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1081)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.

我用picaso来显示图片:

   File f = new File(arrayList.get(position).getImagepath());
Picasso.with(context)
        .load(f)
        .resize(sizeX, sizeY)
        .centerCrop()
        .error(R.drawable.logo).placeholder(R.drawable.logo)
        .into(mainHolder.bookImage);

0 个答案:

没有答案