setTextAppearance deprecated in API level 23

前端 未结 3 684
南旧
南旧 2020-12-14 05:29

public void setTextAppearance (Context context, int resId) Added in API level 1
This method was deprecated in API level 23. Us

3条回答
  •  醉梦人生
    2020-12-14 06:06

    You can use TextViewCompat from the support/androidX library:

        import android.support.v4.widget.TextViewCompat // for support-library
        import androidx.core.widget.TextViewCompat      // for androidX library
    
        // ...
    
        TextViewCompat.setTextAppearance(view, resId)
    

    Internally it gets the context from the view (view.getContext()) on API < 23.

    Source for TextViewCompat

    Source for TextView (API23)

提交回复
热议问题