在2.2下使用GridLayout 及GridLayout包下载

来源:互联网 发布:陕西省家长网络学校 编辑:程序博客网 时间:2024/06/10 15:29
并不是在项目下面加入android-support-v7-gridlayout.jar
正确的使用方法如下:
在使用gridlayout中遇到

Caused by: java.lang.NoClassDefFoundError: android.support.v7.gridlayout.R$dimen

问题,网上很多人碰到,但是也没有找到解决方法。
无意中解决了该问题,特记录。
1.libs文件夹中添加android-support-v7-gridlayout.jar包;
2.eclipse中将android-sdk-windows\extras\android\compatibility\v7\gridlayout工程导入,并添加到需要使用gridlayout工程中,作为lib project处理
上面2个步骤缺一不可。
一开始只有上面的2个之一,一直报异常。

1 在SDK目录下的  \extras\android\support\v7下有 gridlayout 项目,是个library项目, 导入eclipse 稍微调试一下,就不报错了(附件就是)
2  在自己的项目上右键-->属性-->android-->library里面添加上面的项目
3  按照下面的demo使用就可以啦


<android.support.v7.gridlayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.example.androidtest"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:alignmentMode="alignBounds"
    app:columnCount="3"
    app:columnOrderPreserved="false"
    app:rowCount="5"
    app:useDefaultMargins="true" >


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        app:layout_rowSpan="2"
        android:text="@string/hello_world" />


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        app:layout_rowSpan="1"
        android:text="@string/hello_world" />


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        app:layout_rowSpan="3"
        android:text="@string/hello_world" />


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        app:layout_rowSpan="1"
        android:text="@string/hello_world" />


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        app:layout_rowSpan="1"
        android:text="@string/hello_world" />

</android.support.v7.gridlayout>

下载:http://download.csdn.net/detail/irizhao/7691747 

0 0
原创粉丝点击