2017年8月25日 星期五

How to disable click event on TabLayout

Reference:

https://stackoverflow.com/questions/37809538/how-can-i-disable-click-on-tablayout-in-android

Code snippet:

mTabLayout = (TabLayout) findViewById(R.id.tab_layout);

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;
        }
    });
}

沒有留言: