禁用 TabLayout [英] Disable TabLayout
本文介绍了禁用 TabLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用设计库提供的新类:TabLayout.而且我希望在特定情况下,我正在使用的那个不能再更改选项卡了.
I'm using the new class provided by the design library : TabLayout. And I want in specific cases that the one I'm using can't change tab anymore.
我设法在其视图页面上禁用了滑动,但我不知道如何通过单击选项卡来禁用页面更改.
I manage to disable swipe on its viewpager but I can't figure out how to disable the change of page by clicking on tabs.
提前致谢.
推荐答案
我遇到了同样的问题,我使用以下代码解决了在选项卡上禁用触摸事件的问题:
I had the same problem and I solved it disabling touch event on tabs with the following code:
LinearLayout tabStrip = ((LinearLayout)mTabLayout.getChildAt(0));
for(int i = 0; i < tabStrip.getChildCount(); i++) {
tabStrip.getChildAt(i).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
}
这篇关于禁用 TabLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文