title: Android Display Invisible View in Table row
body: <p>Hey in my code I have a table which is being populated dynamically by a method that I call. The table row when added has an invisible view which I would like to display for each particular row when its clicked and all the others to remain hidden here is my code</p>
  
  <pre><code>public void createTable(String itemName,String itemQuantity,String itemPrice,String itemAmount){
      final TableRow tr1 = new TableRow(getApplicationContext());
      tr1.setId(id);
      tr1.setClickable(true);
  
      tr1.setOnClickListener(new View.OnClickListener(){
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
          for(int i = 0;i&lt;lytTableData.getChildCount();i++){
          tr1.getChildAt(4).setVisibility(View.INVISIBLE);
          }
          tr1.getChildAt(4).setVisibility(View.VISIBLE);
          }
  
      });
  
      tr1.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
      EditText textViewItemQuantity;
      TextView textViewItemName,textViewItemPrice,textViewItemAmount;
  
      textViewItemName= new TextView(this);textViewItemQuantity= new EditText(this);textViewItemPrice= new TextView(this);textViewItemAmount= new TextView(this);
      iv2 = new ImageView(this);
      textViewItemName.setWidth(500);textViewItemQuantity.setWidth(100);textViewItemPrice.setWidth(100);textViewItemAmount.setWidth(100);
      textViewItemName.setLayoutParams(new TableRow.LayoutParams((int) getResources().getDimension(R.dimen.textsize), LayoutParams.WRAP_CONTENT, 6f));
      textViewItemQuantity.setLayoutParams(new TableRow.LayoutParams((int) getResources().getDimension(R.dimen.textsize2), LayoutParams.WRAP_CONTENT, 1f));
      textViewItemPrice.setLayoutParams(new TableRow.LayoutParams((int) getResources().getDimension(R.dimen.textsize2), LayoutParams.WRAP_CONTENT, 1f));
      textViewItemAmount.setLayoutParams(new TableRow.LayoutParams((int) getResources().getDimension(R.dimen.textsize2), LayoutParams.WRAP_CONTENT, 1f));
      textViewItemName.setText(itemName);textViewItemQuantity.setText(itemQuantity);textViewItemPrice.setText(itemPrice);textViewItemAmount.setText(itemAmount);  
      textViewItemQuantity.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Large); textViewItemPrice.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Large);
      textViewItemName.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Large); textViewItemAmount.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Large);
      textViewItemName.setTextColor(0xFF121212);textViewItemQuantity.setTextColor(0xFF121212);textViewItemPrice.setTextColor(0xFF121212);textViewItemAmount.setTextColor(0xFF121212);
      textViewItemName.setPadding(0, 15, 5, 0);textViewItemQuantity.setPadding(0, 15, 5, 0);textViewItemPrice.setPadding(0, 15, 5, 0);textViewItemAmount.setPadding(0, 15, 5, 0);
      textViewItemQuantity.setBackgroundColor(android.R.color.transparent);
      iv2.setLayoutParams(new TableRow.LayoutParams((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
      iv2.setImageResource(R.drawable.delete);
      iv2.setVisibility(View.INVISIBLE);
      textViewItemQuantity.setOnClickListener(editTextRows);
      tr1.addView(textViewItemName);tr1.addView(textViewItemQuantity);tr1.addView(textViewItemPrice);tr1.addView(textViewItemAmount);tr1.addView(iv2);
      lytTableData.addView(tr1, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
      Double intItemAmount = Double.parseDouble(itemAmount);
      intTotalAmount = intTotalAmount + intItemAmount;
      intTotalAmount2 = intTotalAmount2 + intItemAmount;
      txtTotal.setText(String.valueOf(intTotalAmount));
      //txtDiscount.setText("0");
      txtAmount.setText(String.valueOf(intTotalAmount));
      id = id + 1;
          System.out.println(tr1.getId());
  }
  </code></pre>
  
  <p>using this method I'm able to create a new row every time I call it
  what could I be missing to make it work just to be clear what is not working is the displaying of the Invisible View it displays but not the way i want it. I want it to display on the row clicked and all the rest to remain invisible and when another row is clicked it is displayed and all the rest remain invisible</p>