Skip to content

Instantly share code, notes, and snippets.

@codeamt
Last active September 25, 2018 07:49
Show Gist options
  • Save codeamt/e537a99e9355ab797d068c36f9b1c609 to your computer and use it in GitHub Desktop.
Save codeamt/e537a99e9355ab797d068c36f9b1c609 to your computer and use it in GitHub Desktop.
private void populateUI(Sandwich model) {
//get text views
TextView nameView = findViewById(R.id.name_tv);
TextView origin = findViewById(R.id.origin_tv);
TextView aka = findViewById(R.id.also_known_tv);
TextView descView = findViewById(R.id.description_tv);
TextView ingredients = findViewById(R.id.ingredients_tv);
//bind data to views
if(model != null) {
origin.setText(sandwich.getPlaceOfOrigin());
descView.setText(sandwich.getDescription());
nameView.setText(sandwich.getMainName());
/* handle attributes populated with array items */
//other names for sandwich
List<String> other_names = sandwich.getAlsoKnownAs();
aka.setText(other_names);
//ingredients for sandwich
List<String> allIngredients = sandwich.getIngredients();
ingredients.setText(allIngredients);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment