Design Time Data for RecyclerView

Nathan Sokalski 4,111 Reputation points
2021-03-14T20:58:19.38+00:00

I am working on my first Xamarin.Android app, which includes a RecyclerView. I have most of the RecyclerView working, but I cannot find a way to use any kind of design time data. Most controls that displayed collections in Xamarin.Forms & UWP used an ItemsSource property, but RecyclerView's way of doing things seems to involve more codebehind. Even though the XML file used in the Adapter is useful for designing the individual items, it still does not let you seen how they look in the app without doing a debug. Is there a way to apply design time data to RecyclerView?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,971 Reputation points
    2021-03-15T06:22:12.2+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Hi,njsokalski. The VS doesn't provide the layout preview function for a list's items in Xamarin.Android. If you want to get what the item will be like when debugging, you could check the preview of item view layout file which is used to inflate the items for the recyclerView in data Adapter class.

       public class CustomDataAdapter : RecyclerView.Adapter  
       {  
           ...  
           public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)  
           {  
               View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.itemView, parent, false);  
               ...  
           }  
       }  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.