Dynamic UI from JSON template using Litho

691 Views Asked by At

I am working on Dynamic screens using server-driven UI in Android. Ref to this post on Building UI using Litho and JSON. How to make use of a JSON template in Litho to render UI elements. If anyone has worked on it Please post an example.

My JSON template looks something like this

{
  "id":1,
  "AcceptsScan":true,
  "searchable":true,
  "sorting":"Key_column",
  "columns":[
    {
      "name":"My First Name",
      "key":"FirstName",
      "type":""
    },
    {
      "name":"EMpNo",
      "key":"EmpNo",
      "type":""
    },
    {
      "name":"EMp Department",
      "key":"EmpDept",
      "type":""
    }

  ],
  "data" :[
    {
      "FirstName":"first name",
      "EmpNo":"123",
      "EmpDept":""
    },
    {
      "FirstName":"first name",
      "EmpNo":"123",
      "EmpDept":""
    },
    {
      "FirstName":"first name",
      "EmpNo":"123",
      "EmpDept":""
    }
   ]
}

I wanted to create three textviews given in columns array and map the data using the "key" and generate list of data given in data array in my recyclerview.

Thank you

0

There are 0 best solutions below