Get child class name from parent

前端 未结 6 593
广开言路
广开言路 2021-02-06 21:36

I have a base class for my all of activities (ActivityBase) that itself derives from android.app.Activity. In onCreate I want to execute some conditio

6条回答
  •  广开言路
    2021-02-06 22:12

    Instead of using an if statement you should create an abstract method for your conditional logic. Then have the child class run the code that is correct for it.

    This also will keep you from having to modify the base class every time you create a new child class.

提交回复
热议问题