我正在尝试在我的项目中使用 GridLayout
,但最好使用 Android 支持库,这样我就可以针对较低版本的 API。当我将 GridLayout
拖到图形布局设计器中时,会弹出一条消息,询问我需要一个兼容 14 版以上 API 的库,并询问我是否要安装该库。我点击“安装”并让 Eclipse 执行它的操作,但 Eclipse 图形布局设计器中出现错误:
The following classes could not be instantiated: - android.support.v7.widget.GridLayout See the Error Log ( Window > Show View) for more details."
(这里是screenshot)
根据错误日志,android.support.v7.widget.GridLayout
未能实例化。
最佳答案
确保您已将 GridLayout 库项目作为库添加到您的项目中。
尝试如下导入GridLayout
的库工程
File->Import->Existing Android code into workspace
指定android-sdk-[path]/extras/android/support/v7/gridlayout
确保将 GridLayout
项目作为 Android 库项目导入并复制到您的工作区中。
导入库项目后,将其作为库添加到您的项目中,如下所示:
右键单击您的项目->Properties->Java Build Path->Order and Export
,其中勾选所有选项。
关于java - android.support.v7.widget.GridLayout 实例化失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21299597/