java - LinearLayout cannot be cast to a class I've created -
java - LinearLayout cannot be cast to a class I've created - my exception: caused by: java.lang.classcastexception: android.widget.linearlayout cannot cast dismo.ufrj.br.bradmobile.headerclass i've created class, headerclass, extends linearlayout. cant seem cast right way.(header linearlayout) here's code headerclass = (headerclass) findviewbyid(r.id.header); the problem stated in error message: layout contains linearlayout , , effort cast own class. can't that. instead, need alter xml read: <dismo.ufrj.br.bradmobile.headerclass .... .... .... > .... </dismo.ufrj.br.bradmobile.headerclass> inheritance doesn't matter much here, since headerclass extends linearlayout , cast above xml linearlayout in code. java android android-layout android-linearlayout