IntelliJ and android.support.v7.widget.GridLayout

后端 未结 3 1908
傲寒
傲寒 2020-12-07 03:18

I am running into trouble either setting up the support v7 GridLayout library in my IntelliJ project, or properly referencing it in my code.

I currently use the Acti

相关标签:
3条回答
  • 2020-12-07 03:28

    You only need to add the support gridlayout to your dependencies now.

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

    Then check the README instructions located in sdk/extras/android/support/v7/gridlayout. Most notably, you have to use the xmlns:app="http://schemas.android.com/apk/res-auto" namespace for some of the attributes.

    <android.support.v7.widget.GridLayout xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:orientation="horizontal"
        app:columnCount="8"
        app:rowCount="8">
    
    0 讨论(0)
  • 2020-12-07 03:45

    Ok, I figured this out. Turns out it was a configuration issue. Here is what I did to set up the support GridLayout library, as well as reference the classes in code.

    • Copy [android-sdk-folder]/extras/android/support/v7/gridlayout folder to your project libs folder

    Set up support GridLayout library in IntelliJ:

    • Project Structure -> Modules in Project Settings pane -> New Module
    • Create module from scratch -> Next
    • Name the project, browse to your libs/gridlayout folder and choose as Content Root, leave the Module Root set by the Content Root assignment, and select Android Module type -> Next
    • Do not create source directory -> Next
    • Do not create Android application structure -> Finish
    • Select Facets in Project Settings pane -> Select your new module -> Check 'Is Library Project'

    Add dependancy to project in IntelliJ:

    • Select Modules in Project Settings pane -> Select the project in which you wish to use the support GridLayout
    • Select Dependancies tab -> click [+] to add new Module Dependancy
    • Select your support library from previous section

    You also need to add a reference to the support v7 GridLayout jar file in the support project libs dir.

    • Still on Dependancies tab -> click [+] to add new Library -> Java
    • Browse to the libs/gridlayout/libs folder and select the support v7 GridLayout .jar
    • Select level (I only needed Project level) -> OK

    Hopefully this helps someone else - I wasted most my day on it. =|

    0 讨论(0)
  • 2020-12-07 03:45

    A little simpler solution:

    First you need to add dependency to gradle anyway, so open build.gradle and

    dependencies {
        compile 'com.android.support:support-v4:13.0.+'
        compile "com.android.support:gridlayout-v7:18.0.+"
    }
    

    This is what http://developer.android.com/tools/support-library/setup.html# but it does not seem to work fully. So then you need to make android studio recognize it.

    1. File > Import Module
    2. Navigate to sdk/extras/android/support/v7/gridlayout

    after rebuilding project it started working for me.

    0 讨论(0)
提交回复
热议问题