This is a Custom Simple-Popup for Android.
Add below code in gradle (project)
- gradle past version
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- gradle current version
pluginManagement {
repositories {
gradlePluginPortal()
google()
maven { url "https://jitpack.io" } // add this line
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
maven { url "https://jitpack.io" } // add this line
}
}
- Add below codes in gradle (module)
dependencies {
implementation 'com.github.cheonjoosung:Android-Simple-Popup:0.0.1'
}
tv.setOnClickListener {
val list = mutableListOf<SimplePopupValue>().apply {
add(SimplePopupValue("menu_title_01", R.mipmap.ic_launcher))
add(SimplePopupValue("menu_title_02", R.mipmap.ic_launcher))
add(SimplePopupValue("menu_title_03", R.mipmap.ic_launcher))
}
val popup = SimplePopup(
context = applicationContext,
popupList = list,
menuTitleColor = Color.RED, // option menuItem TitleColor default black
menuVLineColor = Color.YELLOW // option menuItem V underlineColor default black
) { _, popupValue, position ->
when (position) {
0 -> {
Toast.makeText(
applicationContext,
"Clicked $position ${popupValue.title}",
Toast.LENGTH_SHORT
).show()
}
1 -> {
Toast.makeText(
applicationContext,
"Clicked $position ${popupValue.title}",
Toast.LENGTH_SHORT
).show()
}
2 -> {
Toast.makeText(
applicationContext,
"Clicked $position ${popupValue.title}",
Toast.LENGTH_SHORT
).show()
}
}
}.apply {
isOutsideTouchable = true
isTouchable = true
}
// option menuItem Background
popup.setSimplePopupBackGround(Color.BLUE)
popup.showAsDropDown(it, 60, 10)
}