ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
代理模式  之前的使用如下。Activity和Fragment同时implement AppTitle ~~~ public abstract class BaseActivity extends Activity implements Handler.Callback, AppTitle { ~~~ ~~~ public class BaseFragment extends Fragment implements AppTitle ~~~ 修改后的 ~~~ public class BaseFragment extends Fragment { private AppTitle appTitle; @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Log.d("fragment:onCreateView", getView()); // appTitle = new TitleMgr(getActivity(), getView()); appTitle.initTitle(); } public AppTitle getAppTitle() { return appTitle; } public void setAppTitle(AppTitle appTitle) { this.appTitle = appTitle; } ~~~ 采用策略模式 如果某个BaseFragment的样式不太一样,可以重新AppTitle模块。同时又不影响整体app的使用。 默认的实现类是TitleMgr