已经为此苦苦挣扎了几个小时,不知道为什么我无法编译该死的东西。当我尝试包含 android.support.v7.widget.GridLayout 时,我在预览窗口中看到以下错误:
Rendering Problems The following classes could not be instantiated:
- android.support.v7.widget.GridLayout (Open Class, Show Exception)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE Exception Details java.lang.ClassNotFoundException:
android.support.v7.gridlayout.R$dimen at
java.net.URLClassLoader$1.run(URLClassLoader.java:202) at
java.security.AccessController.doPrivileged(AccessController.java:-2) at
java.net.URLClassLoader.findClass(URLClassLoader.java:190) at
java.lang.ClassLoader.loadClass(ClassLoader.java:306) at
java.lang.ClassLoader.loadClass(ClassLoader.java:247) at
android.support.v7.widget.GridLayout.<init>(GridLayout.java:255) at
android.support.v7.widget.GridLayout.<init>(GridLayout.java:274) at
java.lang.reflect.Constructor.newInstance(Constructor.java:513) at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755) at
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at
android.view.LayoutInflater.rInflate(LayoutInflater.java:727) at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758) at
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at
android.view.LayoutInflater.rInflate(LayoutInflater.java:727) at
android.view.LayoutInflater.inflate(LayoutInflater.java:492) at
android.view.LayoutInflater.inflate(LayoutInflater.java:373)
当我尝试编译时,我尝试使用表单的每个 GridLayout 属性都会出现许多错误:
view_edit_profile.xml:26: error: No resource identifier found for attribute 'orientation' in package 'com.company'
我已将 SDK (/extras/android/support/v7/gridlayout) 中的 gridlayout 模块复制到与我的主项目模块相同的顶级目录中。我已将 gridlayout 模块设置为我的主模块的模块依赖项,并将 android-support-v7-gridlayout.jar 添加为项目的库。
任何建议表示赞赏!
更新(发布 xml):
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.company"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
android:paddingTop="@dimen/abs__action_bar_default_height"
android:paddingLeft="@dimen/margin_med"
android:paddingRight="@dimen/margin_med"
android:id="@+id/scrollView">
<LinearLayout
android:id="@+id/linearLayout_edit_profile"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:paddingBottom="@dimen/padding_med">
<android.support.v7.widget.GridLayout
xmlns:grid="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridLayout_pics"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
grid:orientation="horizontal"
grid:columnCount="3"
grid:rowCount="3"
grid:useDefaultMargins="true">