Im trying to implement a Google sign in button:
In my mainactivity I have:
private GoogleApiClient mGoogleApiClient;
//used to identify result
private static final int RC_SIGN_IN = 1253;
private static final String TAG = "SignInActivity";
private TextView responseText;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Create fragment 
    LoginFragment newFragment = new LoginFragment();
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    // Replace whatever is in the fragment_container view with this fragment,
    // and add the transaction to the back stack so the user can navigate back
    transaction.replace(R.id.fragment_container, newFragment);
    //transaction.addToBackStack(null);
    // Commit the transaction
    transaction.commit();
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, (GoogleApiClient.OnConnectionFailedListener) this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
   //WONT WORK
   setDefaults()
}
To set the onclicklistener I want to run the following method to set the listener:
public void setDefaults()
{
    responseText = (TextView)findViewById(R.id.googleResponse);
    SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
    signInButton.setSize(SignInButton.SIZE_WIDE);
    findViewById(R.id.sign_in_button).setOnClickListener(this);
}
I cant call it from the oncreate of the mainactivity because findViewById(R.id.googleResponse); will be null.
I do not want to have my logic in the loginfragment but want it in my mainActivity.
How should I set the onclicklisterner to the sign_in_button (which is in the loginfragment) while avoiding a null ptr.
 
     
    