3

So I have been thinking about it for a long time. Is there a way that can generate a List of Custom Class according to the sampledata used in the recycler view item? It can help in testing UI and save alot time.

<androidx.recyclerview.widget.RecyclerView
            android:id="@+id/posts_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"
            android:orientation="vertical"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            tools:listitem="@layout/layout_item_post" />

For Example in this recycler view i have used tools:listitem="@layout/layout_item_post"

In that layout file, I have used these sample data

tools:src="@tools:sample/avatars"

tools:text="@tools:sample/full_names"

tools:src="@tools:sample/backgrounds/scenic"

What I want is something that can automatically create a custom class from sample data.

class Post {
    private String name;
    private String userImage;
    private String postImage;
}

If you know about some tool, a dependency that can do that let me know or you can give me some guidance to build it. Thanks

Malik Bilal
  • 869
  • 8
  • 25
  • Have you tried using the same xml attribute in java? – Faizan Haidar Khan Dec 02 '21 at 16:29
  • @FaizanHaidarKhan I'm talking about code generation from sample data. Sample data is not used when you build the application. It's just used for previewing purposes. But if there's some tool that can help in manipulating the sample data and converting it into Custom Class it'll be very time saving. – Malik Bilal Dec 02 '21 at 19:08

0 Answers0