ikew0ng / SwipeBackLayout

An Android library that help you to build app with swipe back gesture.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

findViewById的优化及兼容26以及以上的使用

DevenLiang opened this issue · comments

commented

SwipeBackActivity下这段:
@OverRide
public View findViewById(int id) {
View v = super.findViewById(id);
if (v == null && mHelper != null)
return mHelper.findViewById(id);
return v;
}
返回的View,可以兼容sdk27,参考27的fbc做法:

@SuppressWarnings("TypeParameterUnusedInFormals")
@Override
public <T extends View> T findViewById(@IdRes int id) {
    return getDelegate().findViewById(id);
}


这个部分27版本Activity中,findViewById没有带强转的时候,使用其右滑框架,不用再做繁琐的处理强转View的问题。