title: LinearLayout Fragment List refresh
body: <p>This is my fragment class. Every time the "clerkship" is being changed,</p>
  
  <p>i tried several methods. </p>
  
  <ol>
  <li><p>Trigger the recreate of the entire activity. This would cause a few seconds lag due to the huge list ( 200+ items being populated for the fragment). </p></li>
  <li><p>I would trigger that displayList found on this fragment from the main activity using findFragmentbyTag.</p></li>
  <li><p>Delete all childView from mainActivity and add them back in. </p></li>
  </ol>
  
  <p>Is there any other solution (or which of the above solution) such that i can "refresh" this list(Fragment) populated using multiple linearlayout in a quick and efficient method "instantly".</p>
  
  <p>Just to add on i'm on V4 Fragment and fragments generated dynamically using PagerAdapter from main activity. Thanks so much! </p>
  
  <pre><code>public class EncounterFragment extends Fragment {
  
      ListView list;
      TextView eid;
      TextView eclerkship;
      TextView ename;
      TextView etype;
      TextView erequiredattempts;
  
  
      // DATABASE ADAPTOR
      private eAndPDbAdapter encounterDB;
      private Context myContext = getActivity();
  
      //arrayAdapter
      ListAdapter adapter;
      CheckBox cBox = null; 
  
      //Button Btngetdata;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; encountersList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      //various layout
      ListView encounterList;
  
      static String value;
      private EditText filterText = null;
  
      private  Cursor mCursor; 
      private Cursor cCursor; 
  
      String clerkShip = "null"; 
  
  
  
      //JSON Node Names 
      private static final String TAG_ENCOUNTERS = "encounters";
      private static final String TAG_E_ID = "e_id";
      private static final String TAG_E_CLERKSHIP = "clerkship";
      private static final String TAG_E_NAME = "encounter_name";  
      private static final String TAG_E_TYPE = "type";
      private static final String TAG_E_REQUIRED_ATTEMPTS = "required_attempts";
  
      //JSONArray android = null;
  
  
      private List&lt;String&gt; nameList = new ArrayList(); 
      private List&lt;String&gt; idList = new ArrayList(); 
      private List&lt;String&gt; typeList = new ArrayList(); 
      private List&lt;String&gt; countList = new ArrayList(); 
      public  List encounterSelected = new ArrayList();   
  
  
      public static final String ARG_SECTION_NUMBER = "section_number";
  
      public EncounterFragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          myContext = getActivity();
  
          View rootView = inflater.inflate(R.layout.activity_encounter,
                  container, false);
  
             encountersList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              displayList();
              LinearLayout parentLayout = (LinearLayout) rootView.findViewById(R.id.encounterslist);
  
  
              for(int i = 0 ; i&lt;nameList.size();i++)
              {
                  View v = getLayoutInflater(savedInstanceState).inflate(R.layout.list_v, null);
                  final LinearLayout single = (LinearLayout) v.findViewById(R.id.listV);
                  single.setOnClickListener(new View.OnClickListener() {
  
                      @Override
                      public void onClick(View v) {
                          LinearLayout nestedLL  = (LinearLayout) single.getChildAt(1);
                          CheckBox cb = (CheckBox) nestedLL.getChildAt(0);
                          if(cb.isChecked())
                          {
                              cb.setChecked(false);
                              single.setBackgroundColor(Color.TRANSPARENT);
                          }
                          else
                          {
                              cb.setChecked(true);
                              single.setBackgroundColor(Color.rgb(255, 215, 0));;
                          }
                      }
                  });
                  TextView ID = (TextView) v.findViewById(R.id.eid);
                  TextView name = (TextView) v.findViewById(R.id.ename);
                  TextView count = (TextView) v.findViewById(R.id.eCount);
  
                  String nameValue = nameList.get(i).toString();
                  String IDValue = idList.get(i).toString();
                  String typeValue = typeList.get(i).toString(); 
              String countValue = countList.get(i).toString();
  
                  if (typeValue.equals("Must see"))
                  {
                      nameValue = nameValue + "**";
                  }
                  else
                  {
                      nameValue = nameValue + "*";
                  }
  
                  name.setText(nameValue);
                  ID.setText(IDValue);
                  count.setText(" (" + countValue + ")");
                  parentLayout.addView(v);
              }
  
  
  
          return rootView;
      }
  
      public void displayList()
      {
            displaySharedPreferences();
  
          encounterDB = new eAndPDbAdapter(myContext);
          encounterDB.open();
          mCursor = encounterDB.retrieveAllEncounterCursor(clerkShip);
          if ((mCursor != null) &amp;&amp; (mCursor.getCount() &gt; 0)) {
              mCursor.moveToFirst();
              {
              do {
                  String eID = mCursor.getString(1);
                  String encounter_name = mCursor.getString(3);
                  String encounter_type = mCursor.getString(4);
                  this.idList.add(eID);
                  this.nameList.add(encounter_name);
                  this.typeList.add(encounter_type);
                  //change to procedure if this is procedure 
                  cCursor = encounterDB.retrieveEncounterCounterBasedOnID(eID);
                  int count2 =cCursor.getCount();
                  if ((cCursor != null) &amp;&amp; (count2 &gt; 0)) {
                      cCursor.moveToFirst();
                      String NumCount = cCursor.getString(3);
                      this.countList.add(NumCount);
                  }
                  else
                  {
                      this.countList.add("0");
                  }
  
              }
  
              // move to the next row
              while (mCursor.moveToNext());
      }
          }
          encounterDB.close(); 
  
      }
  
  
  
  public void displaySharedPreferences() {
      SharedPreferences prefs = PreferenceManager
              .getDefaultSharedPreferences(myContext);
  
      String listPrefs = prefs.getString("listpref", "No Clerkship Selected");
  
      StringBuilder builder2 = new StringBuilder();
      builder2.append(listPrefs);
  clerkShip = builder2.toString();
  }   
  }
  </code></pre>