How to use androidx.recyclerview.widget.RecyclerView with tools:listitem?












2















How to use androidx.recyclerview.widget.RecyclerView with tools:listitem?
I have this layout:



<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recyclerViewActors"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/list_item_actor"
tools:itemCount="5"
tools:orientation="horizontal"
tools:scrollbars="horizontal"
tools:spanCount="2"/>


but Design tab doesn't show preview:



enter image description here



And if I change androidx.recyclerview.widget.RecyclerView in this layout to ListView, the preview works:



enter image description here










share|improve this question























  • I copy past your code and is when I add this line tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" in my code I have the same issue (don't see my items) so you can remove it if is not needed

    – Crammeur
    Aug 4 '18 at 15:59











  • @crammeur, but I have this issue and without this line

    – Ksenia
    Aug 4 '18 at 16:06











  • I see in the display of android studio this java.lang.ClassNotFoundException: androidx.recyclerview.widget.GridLayoutManager can explain why you can't have the display. So he can't display because he not find this

    – Crammeur
    Aug 4 '18 at 16:11













  • Do you use implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01' or implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1' because when I use alpha I can see but when I change I don't see preview

    – Crammeur
    Aug 4 '18 at 16:57
















2















How to use androidx.recyclerview.widget.RecyclerView with tools:listitem?
I have this layout:



<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recyclerViewActors"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/list_item_actor"
tools:itemCount="5"
tools:orientation="horizontal"
tools:scrollbars="horizontal"
tools:spanCount="2"/>


but Design tab doesn't show preview:



enter image description here



And if I change androidx.recyclerview.widget.RecyclerView in this layout to ListView, the preview works:



enter image description here










share|improve this question























  • I copy past your code and is when I add this line tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" in my code I have the same issue (don't see my items) so you can remove it if is not needed

    – Crammeur
    Aug 4 '18 at 15:59











  • @crammeur, but I have this issue and without this line

    – Ksenia
    Aug 4 '18 at 16:06











  • I see in the display of android studio this java.lang.ClassNotFoundException: androidx.recyclerview.widget.GridLayoutManager can explain why you can't have the display. So he can't display because he not find this

    – Crammeur
    Aug 4 '18 at 16:11













  • Do you use implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01' or implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1' because when I use alpha I can see but when I change I don't see preview

    – Crammeur
    Aug 4 '18 at 16:57














2












2








2








How to use androidx.recyclerview.widget.RecyclerView with tools:listitem?
I have this layout:



<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recyclerViewActors"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/list_item_actor"
tools:itemCount="5"
tools:orientation="horizontal"
tools:scrollbars="horizontal"
tools:spanCount="2"/>


but Design tab doesn't show preview:



enter image description here



And if I change androidx.recyclerview.widget.RecyclerView in this layout to ListView, the preview works:



enter image description here










share|improve this question














How to use androidx.recyclerview.widget.RecyclerView with tools:listitem?
I have this layout:



<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recyclerViewActors"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/list_item_actor"
tools:itemCount="5"
tools:orientation="horizontal"
tools:scrollbars="horizontal"
tools:spanCount="2"/>


but Design tab doesn't show preview:



enter image description here



And if I change androidx.recyclerview.widget.RecyclerView in this layout to ListView, the preview works:



enter image description here







android android-recyclerview preview androidx android-tools-namespace






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 4 '18 at 15:43









KseniaKsenia

7461130




7461130













  • I copy past your code and is when I add this line tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" in my code I have the same issue (don't see my items) so you can remove it if is not needed

    – Crammeur
    Aug 4 '18 at 15:59











  • @crammeur, but I have this issue and without this line

    – Ksenia
    Aug 4 '18 at 16:06











  • I see in the display of android studio this java.lang.ClassNotFoundException: androidx.recyclerview.widget.GridLayoutManager can explain why you can't have the display. So he can't display because he not find this

    – Crammeur
    Aug 4 '18 at 16:11













  • Do you use implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01' or implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1' because when I use alpha I can see but when I change I don't see preview

    – Crammeur
    Aug 4 '18 at 16:57



















  • I copy past your code and is when I add this line tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" in my code I have the same issue (don't see my items) so you can remove it if is not needed

    – Crammeur
    Aug 4 '18 at 15:59











  • @crammeur, but I have this issue and without this line

    – Ksenia
    Aug 4 '18 at 16:06











  • I see in the display of android studio this java.lang.ClassNotFoundException: androidx.recyclerview.widget.GridLayoutManager can explain why you can't have the display. So he can't display because he not find this

    – Crammeur
    Aug 4 '18 at 16:11













  • Do you use implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01' or implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1' because when I use alpha I can see but when I change I don't see preview

    – Crammeur
    Aug 4 '18 at 16:57

















I copy past your code and is when I add this line tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" in my code I have the same issue (don't see my items) so you can remove it if is not needed

– Crammeur
Aug 4 '18 at 15:59





I copy past your code and is when I add this line tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager" in my code I have the same issue (don't see my items) so you can remove it if is not needed

– Crammeur
Aug 4 '18 at 15:59













@crammeur, but I have this issue and without this line

– Ksenia
Aug 4 '18 at 16:06





@crammeur, but I have this issue and without this line

– Ksenia
Aug 4 '18 at 16:06













I see in the display of android studio this java.lang.ClassNotFoundException: androidx.recyclerview.widget.GridLayoutManager can explain why you can't have the display. So he can't display because he not find this

– Crammeur
Aug 4 '18 at 16:11







I see in the display of android studio this java.lang.ClassNotFoundException: androidx.recyclerview.widget.GridLayoutManager can explain why you can't have the display. So he can't display because he not find this

– Crammeur
Aug 4 '18 at 16:11















Do you use implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01' or implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1' because when I use alpha I can see but when I change I don't see preview

– Crammeur
Aug 4 '18 at 16:57





Do you use implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01' or implementation 'androidx.recyclerview:recyclerview:1.0.0-alpha1' because when I use alpha I can see but when I change I don't see preview

– Crammeur
Aug 4 '18 at 16:57












2 Answers
2






active

oldest

votes


















2














From your code it seems that your recyclerview is the root element of the XML, and is missing the reference from xmlns:tools



Try to use another root element, as a constraint layout or even just layout as per example of google sunflowerapp:



<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/plant_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingLeft="@dimen/margin_normal"
android:paddingRight="@dimen/margin_normal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:context="com.google.samples.apps.sunflower.GardenActivity"
tools:listitem="@layout/list_item_plant" />

</layout>





share|improve this answer































    0














    Use



    android.support.v7.widget.RecyclerView
    android.support.v7.widget.GridLayoutManager
    instead of



    androidx.recyclerview.widget.RecyclerView
    androidx.recyclerview.widget.GridLayoutManager






    share|improve this answer
























    • But I want to use namely androidx.recyclerview.widget.RecyclerView, why I can't to see preview for it?

      – Ksenia
      Aug 4 '18 at 16:07











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51687173%2fhow-to-use-androidx-recyclerview-widget-recyclerview-with-toolslistitem%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    From your code it seems that your recyclerview is the root element of the XML, and is missing the reference from xmlns:tools



    Try to use another root element, as a constraint layout or even just layout as per example of google sunflowerapp:



    <layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <androidx.recyclerview.widget.RecyclerView
    android:id="@+id/plant_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    android:paddingLeft="@dimen/margin_normal"
    android:paddingRight="@dimen/margin_normal"
    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
    tools:context="com.google.samples.apps.sunflower.GardenActivity"
    tools:listitem="@layout/list_item_plant" />

    </layout>





    share|improve this answer




























      2














      From your code it seems that your recyclerview is the root element of the XML, and is missing the reference from xmlns:tools



      Try to use another root element, as a constraint layout or even just layout as per example of google sunflowerapp:



      <layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools">

      <androidx.recyclerview.widget.RecyclerView
      android:id="@+id/plant_list"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:clipToPadding="false"
      android:paddingLeft="@dimen/margin_normal"
      android:paddingRight="@dimen/margin_normal"
      app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
      tools:context="com.google.samples.apps.sunflower.GardenActivity"
      tools:listitem="@layout/list_item_plant" />

      </layout>





      share|improve this answer


























        2












        2








        2







        From your code it seems that your recyclerview is the root element of the XML, and is missing the reference from xmlns:tools



        Try to use another root element, as a constraint layout or even just layout as per example of google sunflowerapp:



        <layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools">

        <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/plant_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingLeft="@dimen/margin_normal"
        android:paddingRight="@dimen/margin_normal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:context="com.google.samples.apps.sunflower.GardenActivity"
        tools:listitem="@layout/list_item_plant" />

        </layout>





        share|improve this answer













        From your code it seems that your recyclerview is the root element of the XML, and is missing the reference from xmlns:tools



        Try to use another root element, as a constraint layout or even just layout as per example of google sunflowerapp:



        <layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools">

        <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/plant_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingLeft="@dimen/margin_normal"
        android:paddingRight="@dimen/margin_normal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:context="com.google.samples.apps.sunflower.GardenActivity"
        tools:listitem="@layout/list_item_plant" />

        </layout>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 1 at 12:22









        Tito RezendeTito Rezende

        615




        615

























            0














            Use



            android.support.v7.widget.RecyclerView
            android.support.v7.widget.GridLayoutManager
            instead of



            androidx.recyclerview.widget.RecyclerView
            androidx.recyclerview.widget.GridLayoutManager






            share|improve this answer
























            • But I want to use namely androidx.recyclerview.widget.RecyclerView, why I can't to see preview for it?

              – Ksenia
              Aug 4 '18 at 16:07
















            0














            Use



            android.support.v7.widget.RecyclerView
            android.support.v7.widget.GridLayoutManager
            instead of



            androidx.recyclerview.widget.RecyclerView
            androidx.recyclerview.widget.GridLayoutManager






            share|improve this answer
























            • But I want to use namely androidx.recyclerview.widget.RecyclerView, why I can't to see preview for it?

              – Ksenia
              Aug 4 '18 at 16:07














            0












            0








            0







            Use



            android.support.v7.widget.RecyclerView
            android.support.v7.widget.GridLayoutManager
            instead of



            androidx.recyclerview.widget.RecyclerView
            androidx.recyclerview.widget.GridLayoutManager






            share|improve this answer













            Use



            android.support.v7.widget.RecyclerView
            android.support.v7.widget.GridLayoutManager
            instead of



            androidx.recyclerview.widget.RecyclerView
            androidx.recyclerview.widget.GridLayoutManager







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 4 '18 at 16:02









            Viswanath Kumar SanduViswanath Kumar Sandu

            1,1431715




            1,1431715













            • But I want to use namely androidx.recyclerview.widget.RecyclerView, why I can't to see preview for it?

              – Ksenia
              Aug 4 '18 at 16:07



















            • But I want to use namely androidx.recyclerview.widget.RecyclerView, why I can't to see preview for it?

              – Ksenia
              Aug 4 '18 at 16:07

















            But I want to use namely androidx.recyclerview.widget.RecyclerView, why I can't to see preview for it?

            – Ksenia
            Aug 4 '18 at 16:07





            But I want to use namely androidx.recyclerview.widget.RecyclerView, why I can't to see preview for it?

            – Ksenia
            Aug 4 '18 at 16:07


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51687173%2fhow-to-use-androidx-recyclerview-widget-recyclerview-with-toolslistitem%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas