在不同活动中将JSON数据加载并传递到多个回收器视图中

时间:2018-07-06 13:20:34

标签: android json android-recyclerview

我有一个json数组,我需要在recyclerview内加载配方标题和描述,从而在单击recyclerview列表中的项目时,我想查看配方集,该配方应显示在recyclerview的新活动中列表,然后在此新活动中单击该项目时,应开始一个新活动,该活动应显示配方集的完整详细信息。目前我没有pojo,因为我一直很难尝试找到正确的方法来映射类别数组设置的配方。如果有人可以帮助我提出pojo和正确的适配器,我将不胜感激。这是我的json数据。

[
{
    "id": 1,
    "category_name": "Bread",
    "category_description": "Learn how to bake bread of different types of bread in local flavours and other desired flavours.",
    "recipes_set": [
        {
            "id": 1,
            "category": 1,
            "recipe_name": "Basic homemade bread.",
            "recipe_description": "This easy white bread recipe bakes up deliciously golden brown. There's nothing like the homemade aroma wafting through my kitchen as it bakes.",
            "recipe_ingredients": "1 package (1/4 ounce) active dry yeast. \r\n2-1/4 cups warm water (110° to 115°).\r\n3 tablespoons sugar.\r\n1 tablespoon salt.\r\n2 tablespoons canola oil.\r\n6-1/4 to 6-3/4 cups all-purpose flour",
            "recipe_procedure": "In a large bowl, dissolve yeast in warm water. Add the sugar, salt, oil and 3 cups flour. Beat until smooth. Stir in enough remaining flour, 1/2 cup at a time, to form a soft dough. Turn onto a floured surface; knead until smooth and elastic, 8-10 minutes. Place in a greased bowl, turning once to grease the top. Cover and let rise in a warm place until doubled, about 1-1/2 hours. Punch dough down. Turn onto a lightly floured surface; divide dough in half. Shape each into a loaf. Place in two greased 9x5-in. loaf pans. Cover and let rise until doubled, 30-45 minutes. Bake at 375° for 30-35 minutes or until golden brown and bread sounds hollow when tapped. Remove from pans to wire racks to cool. Yield: 2 loaves (16 slices each).",
            "recipe_servings": 32,
            "recipe_preparation_time": "20 minutes",
            "recipe_cook_time": "30 minutes plus cooling",
            "recipe_difficulty_level": "Moderately easy",
            "recipe_source": "https://www.tasteofhome.com/recipes/basic-homemade-bread"
        }
    ]
}
]

0 个答案:

没有答案