I have a viewpager with undetermined pages, because the user can add pages too. Thats okay, but I have no idea how to make it possible, that my user could delete those pages. I have tried to implement a long click listener on every tab with the code below, but it is not working.
Then how to detect which one tab is clicked?
for (tabCounter = 0; tabCounter < DataOfPages.size(); tabCounter++) {
tabLayout.getTabAt(tabCounter).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
dataSource.open();
dataSource.deleteById(tabCounter);
dataSource.close();
setupViewPager(viewPager);
return true;
}
});
}
Implementation of
LongClick
listener to eachTAB
:Hope this will help~