Created
September 23, 2020 12:50
-
-
Save yusufceylan/ebe0a2c07c7fc367921272e75d2bde5d to your computer and use it in GitHub Desktop.
Custom Info View Adapter
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
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