oligazar
4/9/2018 - 5:49 AM

Popup

  1. ListPopupWindow
  2. PopupMenu
//http://www.informit.com/articles/article.aspx?p=2078060&seqNum=4
btnDocumentType.setOnClickListener {
            val array = arrayOf("Паспорт", "Другой документ")
            val popup = ListPopupWindow(this)
            popup.anchorView = it
            popup.setAdapter(ArrayAdapter(this, android.R.layout.simple_list_item_1, array))
            popup.width = ViewGroup.LayoutParams.MATCH_PARENT
            popup.height = ViewGroup.LayoutParams.WRAP_CONTENT
            popup.isModal = true
            popup.setOnItemClickListener { parent, view, position, id ->
                Log.d("menuItem", "Clicked: ${array[position]}")
                popup.dismiss()
            }
            popup.show()
        }
// http://wptrafficanalyzer.in/blog/a-popup-menu-example-in-android/
btnDocumentType.setOnClickListener {
            val popup = PopupMenu(this, it)
            popup.menu.add("Паспорт\n")
            popup.menu.add("Другой док\n")
            popup.setOnMenuItemClickListener {
                Log.d("menuItem", "Clicked: ${it.title}")
                true
            }
            popup.show()
        }