Android getActivity() is undefined

前端 未结 4 580
别跟我提以往
别跟我提以往 2020-12-15 03:52

I have errors in my class MainActivity.

The error: The method getActivity() is undefined for the type MainActivity

publ         


        
4条回答
  •  遥遥无期
    2020-12-15 04:40

    This is because you're using getActivity() inside an inner class. Try using:

    SherlockFragmentActivity.this.getActivity()

    instead, though there's really no need for the getActivity() part. In your case, SherlockFragmentActivity .this should suffice.

提交回复
热议问题