由于onAttach(Activity)
已被弃用,因此无法运行此代码:
public void onClick(View v) {
if (v == loginButton){
application.getAuth().getUser().setIsLogedIn(true);
callbacks.onLoggedIn();
}
}
public void onAttach(Activity activity){
super.onAttach(activity);
callbacks = (Callbacks) activity;
}
public interface Callbacks{
void onLoggedIn();
}
现在我收到java.lang.NullPointerException
因为callbacks.onLoggedIn()
返回null
我也试过了:
public void onAttach(Context context){
super.onAttach(context);
callbacks = (Callbacks) context.getApplicationContext();
}