Closed arashmidos closed 9 years ago
What really needs to happen is PagerSlidingTabStrip needs to provide a OnLongClickListener. As can bee seen in PagerSlidingTabStrip#addTab()
private void addTab(final int position, View tab) {
tab.setFocusable(true);
tab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
pager.setCurrentItem(position);
}
});
tab.setPadding(tabPadding, 0, tabPadding, 0);
tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}
the TextView isn't set up to respond. A hacky work around:
PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) v.findViewById(R.id.tabs);
tabs.setShouldExpand(true);
tabs.setViewPager(mViewPager);
ViewGroup tabVG = (ViewGroup) tabs.getChildAt(0);
int children = tabVG.getChildCount();
for(int ii=0;ii<children;ii++) {
View vv = tabVG.getChildAt(ii);
vv.setLongClickable(true);
vv.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
toastMessageLong("We just long clicked");
return false;
}
});
}
Thanks.In addition, this way I can have multicolored tabs easily.
I want to handle long click on my tabs to popup a menu for Editing tab's name or Deleting the entire tab hierarchy.But it doesn't work.
tabsStrip.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Log.d(TAG,"something"); return false; } });