title: How to check imageview is empty or not where imageview created programmatically in android
body: <p>I created image view programatically, and need check image view is empty or not.</p>
  
  <p><code>getdrawable(),getHeigt()</code> and <code>getwidth()</code> methodes but it is not working for me.
  Imageview created like this:</p>
  
  <pre><code> ImageView iv = new ImageView(this);
  </code></pre>
  
  <p>code:</p>
  
  <p>public void dynamicTable(String alist[]) throws NullPointerException {</p>
  
  <pre><code>    try {
          TableLayout tl = (TableLayout) findViewById(R.id.main_table1);
          tl.setBackgroundColor(Color.GRAY);
          sizelen = alist.length;
          cam = new Button[sizelen];
          iv = new ImageView[sizelen];
          int k;
  
          for (k = 0; k &lt; sizelen; k++) {
              try {
                  final int j = k;
  
                  TableRow tr_head = new TableRow(this);
                  TableLayout.LayoutParams rowparams = new TableLayout.LayoutParams(
                          TableLayout.LayoutParams.FILL_PARENT,
                          TableLayout.LayoutParams.WRAP_CONTENT);
                  int leftMargin = 2;
                  int topMargin = 1;
                  int rightMargin = 2;
                  int bottomMargin = 1;
  
                  rowparams.setMargins(leftMargin, topMargin, rightMargin,
                          bottomMargin);
                  rowparams.weight = (float) 0.5;
                  tr_head.setLayoutParams(rowparams);
  
                  // tr_head.setId(10);
  
                  tr_head.setBackgroundColor(Color.WHITE);
                  /*
                   * tr_head.setLayoutParams(new LayoutParams(
                   * LayoutParams.FILL_PARENT LayoutParams.WRAP_CONTENT));
                   */
  
                  cam[k] = new Button(this);
                  cam[k].setText(alist[k]);
                  cam[k].setTextColor(Color.WHITE);
                  cam[k].setBackgroundColor(Color.parseColor("#ffab00"));
                  cam[k].setClickable(true);
                  cam[k].setFocusable(true);
                  cam[k].setGravity(Gravity.LEFT);
                  cam[k].setMaxLines(2);
                  cam[k].setPadding(10, 10, -10, 10);
                  cam[k].setAllCaps(false);
                  cam[k].setTextSize(13);
                  cam[k].setLayoutParams(new TableRow.LayoutParams(85,
                          TableLayout.LayoutParams.WRAP_CONTENT));
                  // cam[i].setWidth(150);
                  // cam[i].setEms(0);
  
                  // cam[i].setGravity(25);
                  // cam[i](Gravity.LEFT);
  
                  // cam[i].setLayoutParams(params);
                  cam[k].setOnClickListener(new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          cam[j].setBackgroundColor(Color.GRAY);
                          camera(j);
                      }
                  });
  
                  tr_head.addView(cam[k]); // add the column to the table row
                                              // here
  
                  iv[k] = new ImageView(this);
                  iv[k].setLayoutParams(new TableRow.LayoutParams(
                          TableRow.LayoutParams.WRAP_CONTENT,
                          TableRow.LayoutParams.WRAP_CONTENT));
                  iv[k].setPadding(0, 7, 10, 0);
                  iv[k].setOnClickListener(new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          imageviewOnclick(iv[j]);
                      }
                  });
                  tr_head.addView(iv[k]); // dd the column to the table row
                                          // here
                  tl.addView(tr_head, rowparams);
              } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
          }
      } catch (Exception e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      }
  </code></pre>