title: Dynamic inflating gives me a nullexception
body: <p>I'm making a layout with a LinearLayout. This layout will have another layout inflated inside. Currently, I'm getting problems (nullexceptions) with that. My inflating code is the next:</p>
  
  <pre><code>private void addLayoutInvoices() {
  
          LinearLayout ll_invoices = new LinearLayout(getActivity());
          ll_invoices.setGravity(Gravity.CENTER);
          ll_invoices.setOrientation(LinearLayout.VERTICAL);
  
          LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
  
          ll_invoices.setLayoutParams(llp);
  
          ...
  
          if(mas.size() &gt; 0) {
  
              for (int i = 0; i &lt; mas.size(); i++) {
  
                  if(mas.get(i).getStatus() == 1){
  
                      View newGratLayout = LayoutInflater.from(getActivity()).inflate(R.layout.albaran_invoices_row, ll_invoices_layer, false);
  
                      newGratLayout.setId(i + 8000);
  
                      RelativeLayout rl_albaran_invoices_row = (RelativeLayout) newGratLayout.findViewById(R.id.rl_albaran_invoices_row);
                      final LinearLayout ll_details = (LinearLayout) newGratLayout.findViewById(R.id.ll_details);
  
                      ...
  
                      rl_albaran_invoices_row.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                              if (!rowClicked) {
                                  ll_details.setVisibility(View.VISIBLE);
                                  rowClicked = true;
                              } else {
                                  ll_details.setVisibility(View.GONE);
                                  rowClicked = false;
                              }
                          }
                      });
  
                      ll_invoices.addView(newGratLayout);
                  }
  
              }
  
              ll_invoices_layer.addView(ll_invoices);
  
              if(existsPending)
                  bt_resend_pending.setVisibility(View.VISIBLE);
          }
  
  
  
      }
  </code></pre>
  
  <p>albaran_invoices_row.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/rl_albaran_invoices_row"
      android:scrollIndicators="none"&gt;
  
      ...
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The logcat shows an error NullPointerException in the line <strong>rl_albaran_invoices_row.setOnClickListener...</strong>. What I'm doing wrong?</p>
  
  <p><strong>NOTE:</strong> I'm doing this from a Fragment.</p>