Button setOnClickListener onCreateView() or onActivityCreated() in Fragment
<p><a href="https://stackoverflow.com/a/32656807/3838663">by this answer</a>
I can't understand where to put my <code>onClickListener()</code> - inside <code>onCreateView()</code> or inside <code>onActivityCreated()</code> , below codes describe it better:</p>

<p><strong>CODE A:</strong> (Setting Button click listener inside <code>onActivityCreated()</code>) </p>

<pre><code>  private FloatingActionButton bt;      

  @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              // do something.
            }
        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.first_frag, container, false);
        bt = (FloatingActionButton) v.findViewById(R.id.fab);
        return v;
    }
</code></pre>

<p><strong>CODE B:</strong> (Setting Button click listener inside <code>onCreateView()</code>)</p>

<pre><code>    private FloatingActionButton bt;      

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.first_frag, container, false);
        bt = (FloatingActionButton) v.findViewById(R.id.fab);
        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              // do something.
            }
        });            
        return v;
    }
</code></pre>

<p>I may have not understood which code is better because of my poor English, anyway, thank you all :)</p>