use*_*680 23 android grid-layout android-gridlayout android-support-library
我有一个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)
如果上述解决方案都不起作用,我可能做错了什么?有什么我想念的,也许我的原始代码有问题吗?
任何帮助表示赞赏
Igo*_*sky 51
尝试使用Gradle,并在build.gradle文件中添加以下部分:
dependencies {
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
Run Code Online (Sandbox Code Playgroud)
然后执行assembleDebug gradle任务.
使用 Android Studio:
进入build.gradle并添加:
compile 'com.android.support:appcompat-v7:18.0.+'
Run Code Online (Sandbox Code Playgroud)
在你的依赖中。
单击 AVD 管理器左侧的图标来同步您的项目。它将实现该库
然后再试一次
使用 Eclipse 试试这个:Gridview v7 support for old api android.support.v7.widget.Gridlayout failed to instaniate
| 归档时间: |
|
| 查看次数: |
31494 次 |
| 最近记录: |