【发布时间】:2014-01-30 14:59:34
【问题描述】:
我正在 Eclipse 上开发这个 android 项目。我在主要活动上创建了两个 gridLayouts 和一个文本字段。它继续在窗口中显示此警告“无法实例化以下类: - android.support.v7.widget.GridLayout(打开类,显示错误日志)”但是当我尝试向 GridLayout 添加一个按钮时,活动冻结,现在它显示以下消息“注意:此项目包含 Java 编译错误,这可能会导致自定义视图的渲染失败。先修复编译问题。
渲染期间引发异常:com.android.layoutlib.bridge.MockView 无法转换为 android.view.ViewGroup 异常详细信息记录在窗口 > 显示视图 > 错误日志中 无法实例化以下类: - android.support.v7.widget.GridLayout(打开类,显示错误日志)”我的xml文件是:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
tools:context=".MainActivity"
xmlns:app="http://schemas.android.com/apk/res/com.example.simple_calculator">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="94dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<android.support.v7.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="232dp"
android:layout_marginTop="100dp" >
</android.support.v7.widget.GridLayout>
<android.support.v7.widget.GridLayout
android:layout_width="232dp"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
app:columnCount="1" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_column="0"
app:layout_gravity="left|top"
app:layout_row="0"
android:text="Button" />
</android.support.v7.widget.GridLayout>
</FrameLayout>
我已经尝试导入 android-sdk-[platform]/extras/android/support/v7/gridlayout,但还是同样的错误。
【问题讨论】:
标签: java android eclipse grid-layout