title: How do I make separators for a ListView with a SimpleAdapter
body: <p>I'm new to the java programming language and I'm trying to build an app. The app has to make a list of worked hours that have been saved in an MySQL database. I found an example app, that helped me retrieving the data from the database and putting it in a ListView. 
  But now we get to my problem. I want to put separators in the listview.</p>
  
  <p>Now, the date of the worked hours is in every item of the ListView. I want the date only above the first item.</p>
  
  <p>I've searched the internet for a way to do this, but it didn't help me. </p>
  
  <p>This it the code that gets the data and puts it in a ListView:</p>
  
  <pre><code>    public class AllUrenActivity extends ListActivity {
      String url_all_uren;
      String ip;
      String proid;
      String uid = MainScreenActivity.uid;
      String datum;
      String datum1;
      ImageView btntoevoegen;
  // Progress Dialog
  private ProgressDialog pDialog;
  
  
      TextView tvDatum;
  
  // Creating JSON Parser object
  JSONParser jParser = new JSONParser();
  
  ArrayList&lt;HashMap&lt;String, String&gt;&gt;urenList;
  
      // JSON Node names
  private static final String TAG_SUCCESS = "success";
  private static final String TAG_UREN = "uren";
  private static final String TAG_TRID = "trid";
  private static final String TAG_PROID = "proid";
  private static final String TAG_WERKZAAMHEID = "werkzaamheid";
  private static final String TAG_TIJD = "tijd";
  private static final String TAG_DATUM = "datum";
  
  // products JSONArray
  JSONArray uren = null;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.all_uren);
  
      SharedPreferences settings = getSharedPreferences("databaseIP", 0);
      ip = settings.getString("ip", "").toString();
      url_all_uren = ("http://"+ip+"/android_connect/get_all_uren.php");
  
  
      // Hashmap for ListView
      urenList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      // Loading products in Background Thread
      new LoadAllUren().execute();
  
      // Get listview
      ListView lv = getListView();
  
  
      // on selecting single product
      // launching Edit Product Screen
      lv.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                  int position, long id) {
              // getting values from selected ListItem
              String proid = ((TextView) view.findViewById(R.id.tvProid)).getText()
                      .toString();
              String werkzaamheid = ((TextView) view.findViewById(R.id.tvWerkzaamheid)).getText()
                      .toString();
              String trid = ((TextView) view.findViewById(R.id.tvTrid)).getText()
                      .toString();
              // Starting new intent
              Intent in = new Intent(getApplicationContext(),
                      AllProjectsActivity.class);
              // sending pid to next activity
              in.putExtra(TAG_PROID, proid);
              in.putExtra(TAG_TRID, trid);
              in.putExtra(TAG_WERKZAAMHEID, werkzaamheid);
              // starting new activity and expecting some response back
              startActivityForResult(in, 100);
  
          }
      });
  
  }
  
  // Response from Edit Product Activity
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      // if result code 100
      if (resultCode == 100) {
          // if result code 100 is received 
          // means user edited/deleted product
          // reload this screen again
          Intent intent = getIntent();
          finish();
          startActivity(intent);
      }
  
  }
  
  /**
   * Background Async Task to Load all product by making HTTP Request
   * */
  class LoadAllUren extends AsyncTask&lt;String, String, String&gt; {
  
      /**
       * Before starting background thread Show Progress Dialog
       * */
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          pDialog = new ProgressDialog(AllUrenActivity.this);
          pDialog.setMessage("Uren laden...");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(false);
          pDialog.show();
      }
  
  
      /**
       * getting All products from url
       * */
      protected String doInBackground(String... args) {
  
  
  
  
          // Building Parameters
          List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
          params.add(new BasicNameValuePair("uid", uid));
  
          // getting JSON string from URL
          JSONObject json = jParser.makeHttpRequest(url_all_uren, "GET", params);
  
          // Check your log cat for JSON reponse
          Log.d("Uren: ", json.toString());
  
          try {
              // Checking for SUCCESS TAG
              int success = json.getInt(TAG_SUCCESS);
  
              if (success == 1) {
                  // products found
                  // Getting Array of Products
                  uren = json.getJSONArray(TAG_UREN);
  
                  // looping through All Products
                  for (int i = 0; i &lt; uren.length(); i++) {
                      JSONObject c = uren.getJSONObject(i);
  
                      // Storing each json item in variable
                      String trid = c.getString(TAG_TRID);
                      String proid = c.getString(TAG_PROID);
                      String werkzaamheid = c.getString(TAG_WERKZAAMHEID);
                      String datum = c.getString(TAG_DATUM);
                      String tijd = c.getString(TAG_TIJD);
  
  
                      // creating new HashMap
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      // adding each child node to HashMap key =&gt; value
                      map.put(TAG_TRID, trid);
                      map.put(TAG_WERKZAAMHEID, werkzaamheid);
                      map.put(TAG_PROID, proid);
                      map.put(TAG_TIJD, tijd);
                      map.put(TAG_DATUM, datum);
  
  
                      // adding HashList to ArrayList
                      urenList.add(map);
                  }
              } else {
                  // no products found
                  // Launch Add New product Activity
                  Intent i = new Intent(getApplicationContext(),
                          NewProductActivity.class);
                  // Closing all previous activities
                  i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                  startActivity(i);
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          return null;
      }
  
      /**
       * After completing background task Dismiss the progress dialog
       * **/
      protected void onPostExecute(String file_url) {
          // dismiss the dialog after getting all products
          pDialog.dismiss();
          // updating UI from Background Thread
  
          runOnUiThread(new Runnable() {
              public void run() {
                  /**
                   * Updating parsed JSON data into ListView
                   * */
  
                      ListAdapter adapter = new SimpleAdapter(
                              AllUrenActivity.this, urenList,
                                      R.layout.list_uren, new String[] { TAG_TRID, TAG_PROID, TAG_WERKZAAMHEID, TAG_TIJD, TAG_DATUM},
                              new int[] { R.id.tvTrid, R.id.tvProid, R.id.tvWerkzaamheid, R.id.tvTijd, R.id.tvDatum });
  
                      // updating listview
                      setListAdapter(adapter);
                  }   
  
  
          });
  
      }
  
  }
       }
  </code></pre>
  
  <p>list_uren.xml</p>
  
  <pre><code>        &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical" &gt;
  
  
      &lt;TextView
          android:id="@+id/tvTrid"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:visibility="gone" /&gt;
  
      &lt;!-- Name Label --&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;TextView
              android:id="@+id/tvDatum"
              android:layout_width="269dp"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:paddingLeft="6dip"
  
              android:textAppearance="?android:attr/textAppearanceLarge"
              android:textSize="17sp"
              android:visibility="visible" /&gt;
  
          &lt;ImageView
              android:id="@+id/toevoegen"
              android:layout_width="25dp"
              android:layout_height="25dp"
              android:src="@android:drawable/ic_menu_add" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;TextView
              android:id="@+id/tvTijd"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingLeft="6dip"
  
              android:text="8:00-12:00"
              android:textSize="17sp"
              android:textStyle="bold"
              android:visibility="visible" /&gt;
  
          &lt;TextView
              android:id="@+id/tvProid"
              android:layout_width="138dp"
              android:layout_height="wrap_content"
              android:layout_marginLeft="25dp"
              android:paddingLeft="6dip"
  
              android:text="Project"
              android:textSize="17sp" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;TextView
          android:id="@+id/tvWerkzaamheid"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingLeft="6dip"
          android:paddingTop="6dip"
          android:text="Werkzaamheid"
          android:textSize="17sp" /&gt;
  
          &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>all_uren.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
      &lt;!-- Main ListView 
           Always give id value as list(@android:id/list)
      --&gt;
  
      &lt;ListView
          android:id="@android:id/list"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>What is the best way to get the date separators? Thank you.</p>