我有一个Android项目,大部分菜单和屏幕都使用GridLayout。问题在于,GridLayout只支持API 14及以上版本。
因为我想使应用程序也可用于旧版本的Android,所以尝试使用Android自己的Support Library GridLayout,该库可提供API 7及更高版本的支持。
这正是我所需要的,但无论如何我就是无法让它起作用。我已经尝试了所有这些解释和想法:
等等...
无论我做什么,怎么做,或者使用哪个IDE(无论是Eclipse ADT还是Android Studio),它总是在Layout 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
编辑:供参考,这是我用来创建支持网格布局的代码(直接从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>
我到底做错了什么,以至于上述解决方案都无法奏效?我是否漏掉了什么,或者我的原始代码存在问题?
感谢任何帮助。