android this报错

if (Data.is_login){
TextView tLogin=view.findViewById(R.id.deng);

        tLogin.setText("欢迎您!!!!"+ SaveSharedPreference.getUserName(this));
    }
    TextView textLogin=view.findViewById(R.id.deng);

这一块的 tLogin.setText("欢迎您!!!!"+ SaveSharedPreference.getUserName(this));this报错怎么解决

这个是上下文不对导致的,需要传fragment的上下文,用getContext试试,不行的话可以采用全局的context

传入你这个activity.this试试,例如MainActivity.this

ClassName.this

getContext()