Creating object from OnClickListener interface
问题 OnClickListener is an static interface but I am instantiating from OnClickListener. I'm confused and wondering that can we generate objects from interface in java? Why don't we create concrete class, inherit from OnClickListener interface? 回答1: That is what is known as an anonymous inner class . The Swing documentation for Java Standard Edition covers it here, and I imagine it's used for much the same purpose in Android development. It allows you to more simply hook up various event handler