title: Clear View in Android
body: <p>I am calling the function <code>setLayoutData()</code> for many places i want to clear the view whenever it is called.What is happening now the layout get appends .But i don't want to append how can we clear the view .Please help me this is my function</p>
  
  <pre><code>void setLayoutData() {
          resultTrips = (LinearLayout) findViewById(R.id.trip_list);
          LinearLayout.LayoutParams mainTripDetailsLayout = new LinearLayout.LayoutParams(
                  LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
          LayoutInflater inflater = (LayoutInflater) getBaseContext()
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          for (int i = 0;i&lt;4;i++) {
              final LinearLayout tripdetailsdata = (LinearLayout) inflater
                      .inflate(R.layout.mytripinner, null);
              tripdetailsdata.setId(i);
              resultTrips.addView(tripdetailsdata);
              i++;
          }
          TextView dummy = new TextView(this);
          dummy.setLayoutParams(mainTripDetailsLayout);
          resultTrips.addView(dummy);
      }
  </code></pre>