Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDataClickListener and onDataLongClickListener #207

Open
SennyK22 opened this issue Feb 9, 2023 · 2 comments
Open

onDataClickListener and onDataLongClickListener #207

SennyK22 opened this issue Feb 9, 2023 · 2 comments

Comments

@SennyK22
Copy link

SennyK22 commented Feb 9, 2023

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 ?

@ISchwarz23
Copy link
Owner

Hey, if you return true fromt the TableDataLongClickListener callback, the TableDataClickListener should not be called.

@SennyK22
Copy link
Author

Hi.
Yes, I know it should be, but as you can see, my code has a return true and it does both.
If I longclick and drag my finger somewhere then there is no onClickListener only onLongClickListener

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants