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

[TabLayout] Can't customize TabView click listener #4105

Open
vvinogra opened this issue Mar 17, 2024 · 0 comments · May be fixed by #4107
Open

[TabLayout] Can't customize TabView click listener #4105

vvinogra opened this issue Mar 17, 2024 · 0 comments · May be fixed by #4107

Comments

@vvinogra
Copy link

Description:

I have a business logic in the app to perform a certain validation when the TabView is clicked.
Due to the current TabLayout implementation, I can't prevent tab selection when the tab is clicked.

Expected behavior:

We should have an option to control this behavior.

Source code:
TabLayout.java

    @Override
    public boolean performClick() {
      final boolean handled = super.performClick();

      if (tab != null) {
        if (!handled) {
          playSoundEffect(SoundEffectConstants.CLICK);
        }
        tab.select();
        return true;
      } else {
        return handled;
      }
    }

Minimal sample app repro:

  1. Create Activity/Fragment with TabLayout and a few TabView items.
  2. Click on the tab

Material Library version: 1.11.0

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

Successfully merging a pull request may close this issue.

2 participants