添加recyclerview

时间:2017-12-17 14:41:28

标签: android android-recyclerview

嗨,大家好几天前我刚刚开始学习安卓。我很困惑为什么我的下面的XML代码是错误的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".MainActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimaryDark"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </RelativeLayout>
    </android.support.design.widget.AppBarLayout>
  <android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/appBar"
    android:layout_above="@+id/linear">
  </android.support.v7.widget.RecyclerView>





    <LinearLayout
        android:id="@+id/linear"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true">


        <EditText
            android:id="@+id/etNeme_room"
            android:layout_width="306dp"
            android:layout_height="match_parent"
            />

        <Button
            android:id="@+id/btnAdd_room"
            style="?android:attr/borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:text="Room" />

    </LinearLayout>

</RelativeLayout>

它返回错误:

  

java.lang.NoSuchMethodError:   android.support.v4.view.ViewCompat.getDisplay(Landroid /视图/视图;)Landroid /视图/显示;     在   android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2546)     在android.view.View.dispatchAttachedToWindow(View.java:15395)处   android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2953)     在   android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)     在   android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)     在   android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)     在   android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)     在   com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:333)     在com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)     在   com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)     在   com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:567)     在   com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:549)     在   com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)     在   com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)     在   com.android.tools.idea.rendering.RenderTask.lambda $膨胀$ 1(RenderTask.java:680)     在java.util.concurrent.FutureTask.run(FutureTask.java:266)at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617)     在java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案