Skip to content

Instantly share code, notes, and snippets.

@yusufceylan
Created September 23, 2020 12:50
Show Gist options
  • Save yusufceylan/ebe0a2c07c7fc367921272e75d2bde5d to your computer and use it in GitHub Desktop.
Save yusufceylan/ebe0a2c07c7fc367921272e75d2bde5d to your computer and use it in GitHub Desktop.
Custom Info View Adapter
class CustomInfoViewAdapter constructor(context : Context) : HuaweiMap.InfoWindowAdapter {
private var mWindow: View? = null
init {
mWindow = LayoutInflater.from(context).inflate(R.layout.custom_info_window_layout, null)
}
override fun getInfoWindow(marker: Marker?): View? {
if (marker == null || marker.tag == null)
return null
val tvTitle = mWindow?.findViewById<TextView>(R.id.tv_title)
val tvSnippet = mWindow?.findViewById<TextView>(R.id.tv_snippet)
val tvExtraInfo = mWindow?.findViewById<TextView>(R.id.tv_extra_info)
// Set data to UI
tvTitle?.text = marker.title
tvSnippet?.text = marker.snippet
// Get extra marker info
val markerInfo = marker.tag as String
tvExtraInfo?.text = markerInfo
return mWindow
}
override fun getInfoContents(marker: Marker?): View? {
return null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment