Android how to pass an Activity.class as an argument for a function

后端 未结 7 2293
南方客
南方客 2021-02-12 12:22

I recently moved to Android from python and am stuck here.

This is my class declaration to create a common function for an Alert Dialog which accepts necessary parameter

7条回答
  •  Happy的楠姐
    2021-02-12 12:39

    In Java, each class you write will also have a Class class attached to it. The Class class will be used by the classloader etc.

    As others have said you should use MakeCall.this instead of MakeCall.class because MakeCall.this will point to itself which is an Activity whilst MakeCall.class will point to MakeCall's attached Class class.

提交回复
热议问题