tabLayout.setOnTabSelectedListener

这个虽然简单但还是简单的记录一下:

有三个tablayout,这是每个log日志打印的结果

自己试验过的都能明白这三个状态是什么意思,贴上源码的解释:

 /**
     * Callback interface invoked when a tab's selection state changes.
     */
    public interface OnTabSelectedListener {

        /**
         * Called when a tab enters the selected state.当选项卡进入选定状态时调用。
         *
         * @param tab The tab that was selected选中的选项卡
         */
        public void onTabSelected(Tab tab);

        /**
         * Called when a tab exits the selected state.当选项卡退出所选状态时调用
         *
         * @param tab The tab that was unselected选项卡未选中的选项卡
         */
        public void onTabUnselected(Tab tab);

        /**
         * Called when a tab that is already selected is chosen again by the user. Some applications当用户再次选择已选中的选项卡时调用。一些应用程序可以使用此操作返回到类别的顶层。
         * may use this action to return to the top level of a category.
         *
         * @param tab The tab that was reselected.重新选择的选项卡。
         */
        public void onTabReselected(Tab tab);
    }

 

java.lang.IllegalStateException: Observer com.google.android.material.tabs.TabLayout$PagerAdapterObserver@8b3d524 was not registered. at android.database.Observable.unregisterObserver(Observable.java:69) at androidx.viewpager.widget.PagerAdapter.unregisterDataSetObserver(PagerAdapter.java:312) at com.google.android.material.tabs.TabLayout.setPagerAdapter(TabLayout.java:1506) at com.google.android.material.tabs.TabLayout$AdapterChangeListener.onAdapterChanged(TabLayout.java:3440) at androidx.viewpager.widget.ViewPager.setAdapter(ViewPager.java:549) at com.homily.classgroup.fragment.ClassNewsManagerFragment.initTableFragment(ClassNewsManagerFragment.java:96) at com.homily.classgroup.fragment.ClassNewsManagerFragment.access$300(ClassNewsManagerFragment.java:53) at com.homily.classgroup.fragment.ClassNewsManagerFragment$6.onNext(ClassNewsManagerFragment.java:308) at com.homily.classgroup.fragment.ClassNewsManagerFragment$6.onNext(ClassNewsManagerFragment.java:299) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:210) at android.os.Looper.loop(Looper.java:299) at android.app.ActivityThread.main(ActivityThread.java:8261) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)怎么解决
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值