11

I try to use GridLayout in my App, but it wont work. I used this Tutorial: IntelliJ and android.support.v7.widget.GridLayout

But it still wont work.

I get the following Error:

error: No resource identifier found for attribute 'columnCount' in package 'android'
error: No resource identifier found for attribute 'rowCount' in package 'android'

Any further tips?

EDIT: work with my actual XML:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:grid="http://schemas.android.com/apk/res-auto"
              android:layout_width="350dp"
              android:layout_height="fill_parent"
              android:orientation="vertical">

    <EditText android:layout_height="wrap_content"
              android:layout_width="fill_parent"
              android:cursorVisible="false"
              android:id="@+id/txtName"/>


    <android.support.v7.widget.GridLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            grid:columnCount="3"
            grid:rowCount="2">

        <TextView   
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1,1" />
     
    </android.support.v7.widget.GridLayout>

</LinearLayout>
Community
  • 1
  • 1
Prexx
  • 2,959
  • 5
  • 31
  • 48

2 Answers2

34

Today I struggled with this and on android dev site I found simpler solution and why they're problems with it. GridLayout from v7 libraries aren't connected with v7 appcompat library so you must add v7 gridlayout library dependency manually.

If you use gradle then in build.gradle just add

dependencies {
    ...
    compile 'com.android.support:gridlayout-v7:23.2.0'
}

and everything should works fine :)

wrozwad
  • 2,610
  • 1
  • 30
  • 38
  • 1
    Can someone explain why you need both `com.android.support:appcompat-v7:18.+` and this `gridlayout`-line? What other Views do you need separate includes for? – Nilzor Aug 07 '14 at 09:07
  • 1
    @Nilzor : I found that appcompat and gridlayout are two saparate libraries. Hence they should be mentioned saparately in build.gradle. You can see more details here : http://developer.android.com/tools/support-library/features.html – akshay7692 Feb 02 '16 at 15:36
0

You need to use the full package and class name:

<android.support.v7.widget.GridLayout>

And add the namespace so that other controls will use the default package:

xmlns:grid="http://schemas.android.com/apk/res-auto"
Simon
  • 14,407
  • 8
  • 46
  • 61
  • +1, nice, I didn't know about the grid namespace. I've not used GridLayout yet. – Kevin Coppock Oct 31 '12 at 15:15
  • still wont work. :( i edited my first post. thanks for your help! :) – Prexx Oct 31 '12 at 15:27
  • What did you edit? Are you saying that you used the full package name and added the res-auto namespace and you get the same error? – Simon Oct 31 '12 at 16:36
  • Yes. i edited the xml in my first post. am i doing it right with namespace and full package name? – Prexx Nov 01 '12 at 08:14
  • Yes, still getting errors, that rowCount and columnCount not found. – Prexx Nov 01 '12 at 13:50
  • 6
    `this is not working` - that tells me everything I need to know! – Simon Jun 20 '13 at 19:36
  • Downvoted as it's not working for me and most people :/ The answer below should be accepted imho. – alaeri Jul 17 '15 at 16:16
  • @alaeri Well, I would agree with you, except the question, and my answer from over 2 years ago, was concerning IntelliJ and Ant, not Gradle. Thanks for the incorrect downvote – Simon Jul 17 '15 at 22:59
  • I suggested an edit to redirect other users to the next answer. This will avoid you getting more downvotes and will present an up to date answer. It should be more constructive – alaeri Jul 17 '15 at 23:20