getActivity() where it is defined?

前端 未结 11 1970
温柔的废话
温柔的废话 2020-12-13 10:19

I\'m very new to android and I\'m following this example.

The code says we need to do these steps to get an dialog box:

AlertDialog.Builder builder =         


        
11条回答
  •  无人及你
    2020-12-13 10:24

    This article describes how to create an AlertDialog in a Fragment. in Fragments, you can get the corresponding Activity by calling getActivity() method. but in your case i assume you are doing this in an Activity. so you don't have to call getActivity(). just use this

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    

提交回复
热议问题