0
由於onAttach(Activity)
已被棄用,遇到問題我有運行此代碼的麻煩:方法onAttach(活動)已過時實施onAttach(上下文)
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();
}