我有一个Android项目,它在大多数菜单和屏幕中使用GridLayout.然而问题是从API 14及以后版本支持GridLayout.
由于我想让应用程序也可用于旧版本的android,我尝试使用Android自己的支持库GridLayout,它增加了对API 7的支持.这正是我所寻找的,但是我不能为我的生活让它工作.我尝试了所有这些解释和想法:
和更多...
无论我做什么,我是怎么做的,或者我使用的是什么IDE(无论是Eclipse ADT还是Android Studio),它总是在布局XML中给出一个错误:
The following classes could be instantiated: - android.support.v7.widget.GridLayout
With either one of these exceptions showing in the error log:
1. android.content.res.Resources$NotFoundException: Could not resolve value 0x7F080000
2. java.lang.classnotfoundexception: android.support.v7.gridlayout.R$dimen
Run Code Online (Sandbox Code Playgroud)
编辑:作为参考,这是我用来创建支持gridlayout(直接从android示例程序):
<android.support.v7.widget.GridLayout
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:background="@drawable/blue"
android:padding="10dip"
app:columnCount="4"
>
<TextView
android:text="@string/string_test"
/>
<EditText
app:layout_gravity="fill_horizontal"
app:layout_column="0"
app:layout_columnSpan="4"
/>
<Button
android:text="@string/button_test"
app:layout_column="2"
/>
</android.support.v7.widget.GridLayout>
Run Code Online (Sandbox Code Playgroud)
如果上述解决方案都不起作用,我可能做错了什么?有什么我想念的,也许我的原始代码有问题吗?
任何帮助表示赞赏
android grid-layout android-gridlayout android-support-library
我在IntelliJ项目中设置支持v7 GridLayout库或在我的代码中正确引用它时遇到了麻烦.
我目前在我的项目中使用ActionBarSherlock和Facebook库,并以相同的方式设置了支持GridLayout库(在src文件夹中没有源代码,我告诉IntelliJ使用项目目录作为jar文件夹).一切看起来很好,构建和部署到我的测试设备,但当我试图给布局充气时,我的应用程序崩溃了.
09-17 17:07:43.916: ERROR/AndroidRuntime(4143): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainHostActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.GridLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2753)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.access$2500(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2117)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.GridLayout
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.decoderhq.indieshuffle.PlayerFragment.onCreateView(PlayerFragment.java:63)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
at …Run Code Online (Sandbox Code Playgroud) android intellij-idea grid-layout classnotfoundexception android-support-library