一直在掙扎幾個小時,不知道爲什麼我不能讓該死的東西編譯。當我嘗試包括android.support.v7.widget.GridLayout,我看到下面的錯誤在我的預覽窗口: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)
當我嘗試編譯,我得到了一些對每個網格佈局錯誤的屬性我嘗試使用下面的形式:
view_edit_profile.xml:26: error: No resource identifier found for attribute 'orientation' in package 'com.company'
我已經複製從SDK(/演員/安卓/支持/ V7 /網格佈局)到同一個頂級目錄作爲我的主要項目模塊的網格佈局模塊。我已經將gridlayout模塊設置爲我的主模塊的模塊依賴項,並且還將android-support-v7-gridlayout.jar添加爲該項目的庫。
任何意見讚賞!
UPDATE(發佈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">
請問您可以發表您的view_edit_profile.xml代碼嗎? –
xml發佈,我實際上得到了這個工作,通過解決xmlns,解決方案上面張貼 –