title: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
body: <p>I have dynamic views that I add into linear layout after this I get child that I added to linear layout and set tag to them to identify each dynamic layout when clicking on it when I'm clicking on dynamic layout to replace fragment to seeing detail of clicked view I'm getting this error</p>
  
  <pre><code>Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
  </code></pre>
  
  <p>here is what I'm doing:</p>
  
  <pre><code>for(int i = 0; i &lt; leafletList.getChildCount(); i++){
          leafletList.getChildAt(i).setTag(i);
      }
  </code></pre>
  
  <p>here is what I'm doing when clicking on dynamic view</p>
  
  <pre><code> view.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View view) {
              fragment.replaceLeaflet((Integer)view.getTag(), data);
          }
      });
  </code></pre>
  
  <p>where <code>(Integer)view.getTag()</code> is null, why is it null? anyway I'm setting the tag to each of them</p>
  
  <p>edited:
  this is how I'm adding dynamic views in linear layout defined in xml</p>
  
  <pre><code>String[] disease = {"Colds","Cough"};
      for(int i = 0; i &lt; disease.length ; i++){
          DrReportLeafletLayout leaflet = new DrReportLeafletLayout(getActivity(), disease[i], this, disease);
          leafletList.addView(leaflet);
      }
  </code></pre>
  
  <p>crash stack:</p>
  
  <pre><code>FATAL EXCEPTION: main
                                                                          Process: com.myhealthathand.hah.dev, PID: 25104
                                                                          java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
                                                                              at com.myhealthathand.hah.customviews.DrReportLeafletLayout$1.onClick(DrReportLeafletLayout.java:55)
                                                                              at android.view.View.performClick(View.java:5207)
                                                                              at android.view.View$PerformClick.run(View.java:21168)
                                                                              at android.os.Handler.handleCallback(Handler.java:746)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                              at android.os.Looper.loop(Looper.java:148)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5491)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  </code></pre>