android.app.Application cannot be cast to android.app.Activity

后端 未结 5 1820
日久生厌
日久生厌 2020-11-28 09:33

I\'m trying to change a LinearLayout from another class, but when i run this code:

public class IRC extends PircBot {

ArrayList c         


        
5条回答
  •  广开言路
    2020-11-28 10:11

    You are getting this error because the parameter required is Activity and you are passing it the Application. So, either you cast application to the Activity like: (Activity)getApplicationContext(); Or you can just type the Activity like: MyActivity.this

提交回复
热议问题