简体   繁体   English

Android Studio:无法构建引发错误的1.5版

[英]Android Studio : Can't build throw error version 1.5

Since I have updated my android studio to version 1.5, building project throws me an error while I add new fragment to it 由于我已经将Android Studio更新至版本1.5,因此在向其中添加新片段时,构建项目会引发错误

  @Override
public void onAttach(Activity context) {
    super.onAttach(context);
    if (context instanceof OnFragmentInteractionListener) {
        mListener = (OnFragmentInteractionListener) context;
    } else {
        throw new RuntimeException(context.toString()
                + " must implement OnFragmentInteractionListener");
    }
}

Error thrown on second line of the code ie.. super.onAttach(context) 在代码的第二行上抛出错误,即super.onAttach(context)

Log is shown as @overrride method does not override or implement method of a supertype 日志显示为@overrride method does not override or implement method of a supertype

Try this code for deprecated library.. 尝试使用此代码以弃用库。

@Override
public void onAttach(Context context) {
    super.onAttach(context);

    Activity a;

    if (context instanceof Activity){
        a=(Activity) context;
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM