Home > database >  How I make a page view like a book with JSON data
How I make a page view like a book with JSON data

Time:01-06

please see this image to get my point

I want to get text from JSON and add these texts like series circuit in my layout, but I can't understand how I make this possible.

You see the book lines. One line then second line then third, long lines are wrapped. I want exactly the same thing in my app.

Hope you understand what I wrote.

CodePudding user response:

To create a page view like a book with JSON data in Java, you could follow these steps:

Parse the JSON data: Use a JSON parser library, such as Gson or Jackson, to parse the JSON data into Java objects.

Create a layout for the book view: Use a layout manager, such as a GridBagLayout or a BoxLayout, to arrange the components in the book view.

Display the data in the book view: Iterate through the Java objects and add the data to the book view using swing components, such as labels, text fields, and images.

Add navigation controls: Add buttons or other UI elements to allow the user to navigate through the pages of the book.

Style the book view: Use CSS or Java code to style the book view to give it a desired look and feel.

By following these steps, you can create a page view like a book that displays JSON data in Java. You may need to adapt these steps depending on the specific requirements and constraints of your project.

CodePudding user response:

I found!! https://github.com/google/flexbox-layout this library made my day

Use Flexbox Layout Manager instead of Linear Layout Manager

implementation 'com.google.android.flexbox:flexbox:3.0.0'

Then:

RecyclerView recyclerView = (RecyclerView) context.findViewById(R.id.recyclerview);
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
layoutManager.setFlexDirection(FlexDirection.COLUMN);
layoutManager.setJustifyContent(JustifyContent.FLEX_END);
recyclerView.setLayoutManager(layoutManager);
  • Related