Added setTabLongClickListener(...)

master
Max Ammann 2016-06-14 15:50:19 +02:00
parent 074f064323
commit 64e13276fa
1 changed files with 13 additions and 0 deletions

View File

@ -77,6 +77,8 @@ public class SlidingTabLayout extends HorizontalScrollView {
private final SlidingTabStrip mTabStrip;
private OnLongClickListener tabLongClickListener = null;
public SlidingTabLayout(Context context) {
this(context, null);
}
@ -114,6 +116,16 @@ public class SlidingTabLayout extends HorizontalScrollView {
mDistributeEvenly = distributeEvenly;
}
/**
* Sets the listener for long clicks on tabs
* Should be set before calling {@link #setViewPager(ViewPager)}
*
* @param longClickListener The listener
*/
public void setTabLongClickListener(OnLongClickListener longClickListener) {
this.tabLongClickListener = longClickListener;
}
/**
* Sets the colors to be used for indicating the selected tab. These colors are treated as a
* circular array. Providing one color will mean that all tabs are indicated with the same color.
@ -213,6 +225,7 @@ public class SlidingTabLayout extends HorizontalScrollView {
tabTitleView.setText(adapter.getPageTitle(i));
tabView.setOnClickListener(tabClickListener);
tabView.setOnLongClickListener(tabLongClickListener);
String desc = mContentDescriptions.get(i, null);
if (desc != null) {
tabView.setContentDescription(desc);