Created
July 14, 2018 12:43
-
-
Save VaidotasK/65566c263a49b8aaf720bf1ab5189a90 to your computer and use it in GitHub Desktop.
From PlaceAdapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
// Check if an existing view is being reused, otherwise inflate the view | |
if (convertView == null) { | |
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_place, parent, false); | |
} | |
// Get the {@link Place} object located at this position in the list | |
Place currentPlace = getItem(position); | |
TextView placeNameTextView = convertView.findViewById(R.id.place_name_textView); | |
placeNameTextView.setText(currentPlace.getPlaceName()); | |
ImageView placeImageImageView = convertView.findViewById(R.id.place_image_imageView); | |
if (currentPlace.hasImage()) { | |
placeImageImageView.setImageResource(currentPlace.getPlaceImageResourceId()); | |
placeImageImageView.setVisibility(View.VISIBLE); | |
} else { | |
placeImageImageView.setVisibility(View.GONE); | |
} | |
TextView placeAddressTextView = convertView.findViewById(R.id.place_address_textView); | |
placeAddressTextView.setText(currentPlace.getPlaceAddress()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment