mTabLayout.setOnTabSelectedListener is deprecated

简介: mTabLayout.setOnTabSelectedListener is deprecated

image.png

用addOnTabSelectedListener代替,方法一样。


源码:



/**
     * @deprecated Use {@link #addOnTabSelectedListener(OnTabSelectedListener)} and
     * {@link #removeOnTabSelectedListener(OnTabSelectedListener)}.
     */
    @Deprecated
    public void setOnTabSelectedListener(@Nullable OnTabSelectedListener listener) {
        // The logic in this method emulates what we had before support for multiple
        // registered listeners.
        if (mSelectedListener != null) {
            removeOnTabSelectedListener(mSelectedListener);
        }
        // Update the deprecated field so that we can remove the passed listener the next
        // time we're called
        mSelectedListener = listener;
        if (listener != null) {
            addOnTabSelectedListener(listener);
        }
    }
    /**
     * Add a {@link TabLayout.OnTabSelectedListener} that will be invoked when tab selection
     * changes.
     *
     * <p>Components that add a listener should take care to remove it when finished via
     * {@link #removeOnTabSelectedListener(OnTabSelectedListener)}.</p>
     *
     * @param listener listener to add
     */
    public void addOnTabSelectedListener(@NonNull OnTabSelectedListener listener) {
        if (!mSelectedListeners.contains(listener)) {
            mSelectedListeners.add(listener);
        }
    }

目录
相关文章
|
5月前
|
Java
You may wish to exclude one of them to ensure predictable runtime behavior
You may wish to exclude one of them to ensure predictable runtime behavior
43 1
|
小程序 JavaScript API
Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ?
Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ?
819 0
error ‘.native‘ modifier on ‘v-on‘ directive is deprecated
error ‘.native‘ modifier on ‘v-on‘ directive is deprecated
|
6月前
|
iOS开发
‘authorizationStatus‘ is deprecated: first deprecated in iOS 14.0
‘authorizationStatus‘ is deprecated: first deprecated in iOS 14.0
85 0
|
6月前
Classic mode for store/ is deprecated and will be removed in Nuxt 3
Classic mode for store/ is deprecated and will be removed in Nuxt 3
114 0
|
11月前
|
数据库连接
(node:2612) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
(node:2612) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
|
开发工具
WARNING: library configuration mismatch
WARNING: library configuration mismatch
312 0
libvpx enabled but no supported decoders found
libvpx enabled but no supported decoders found
187 0
|
API Python
全网首发:warning: #warning “Using deprecated NumPy API, disable it by “ “#defining NPY_NO_DEPRECATED_API
全网首发:warning: #warning “Using deprecated NumPy API, disable it by “ “#defining NPY_NO_DEPRECATED_API
278 0