mardi 24 février 2015

Populate multiple TextView from data SQLite

I have this code to populate a TextView from a db :



String ingredients = "";
ArrayList<Map<String, Object>> recipeIngredients = db
.getRecipeIngredients(recipeId);
for (Map<String, Object> ingredient : recipeIngredients)
ingredients += "\n"
+ ingredient.get(RECIPES_INGREDIENTS.ingredientNeed).toString() + " "
+ ingredient.get(RECIPES_INGREDIENTS.unit) + " "
+ ingredient.get(RECIPES_INGREDIENTS.ingredient).toString();
((TextView) findViewById(R.id.recipeIngredients)).setText(ingredients.substring(1));


It works great, but the problem is that, all the ingredients and units are shown in the same textview, i can't get the code to work to show ingredients and units in separate textviews.


Any help is appreciated.


Thanks


Aucun commentaire:

Enregistrer un commentaire