Skip to content

onDataClickListener and onDataLongClickListener #207

Description

@SennyK22

Hello. I'm have problem with listeners.

In my code I'm have that:

tableView.addDataClickListener { rowIndex, clickedData ->
                clickedData as Array<String>
                onResume()
                FancyToast.makeText(
                    this,
                    "Szkolenie: " + clickedData[0] + "\nDzień: " + clickedData[1] + "\nProwadzący: " + clickedData[3],
                    FancyToast.LENGTH_LONG,
                    FancyToast.INFO,
                    false
                ).show()
        }
        tableView.addDataLongClickListener { rowIndex, clickedData ->
                // Utwórz menu kontekstowe

                val popup = PopupMenu(this, View(this))
                popup.inflate(R.menu.contex_menu)

                // Ustaw listener dla pozycji menu
                popup.setOnMenuItemClickListener { item ->
                    when (item.itemId) {
                        R.id.context_menu_edit -> {
                            // Kod dla pierwszej pozycji menu
                            Toast.makeText(this, "Edycja" + rowIndex, Toast.LENGTH_SHORT).show() as Boolean
                        }
                        R.id.context_menu_info -> {
                            // Kod dla drugiej pozycji menu
                            Toast.makeText(this, "Info" + rowIndex, Toast.LENGTH_SHORT).show() as Boolean
                        }
                        else -> return@setOnMenuItemClickListener false
                    }
                    wasLongClick = true
                    true
                }

                // Wyświetl menu kontekstowe
                popup.show()

            Toast.makeText(this, "dsadas" + rowIndex, Toast.LENGTH_SHORT).show() as Boolean
            true
        }

And when Im do long click first that show me action on LongClickListener and then action on ClickListener...

What I'm can do show me only LongListener when do long click ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions