title: How to add Section Header in ListView List Item
body: <p>I want to Develop "History of Country" Android Application. But I have a problem. I can not put Country Header in Listview List Item. I want to put Header; Such as "Africa : North Africa", "Sub-Saharan Africa", "Asia", "North Asia", "West &amp; Central Asia", "South &amp; Southeast Asia", "Europe", "North &amp; Central America", "North America", "Oceania", "South America".<br>
  <strong>Here My Source Code</strong> : <br>
  <a href="https://www.dropbox.com/s/k66xonom9up1yif/Country%20Search%20ListView.zip?dl=0" rel="noreferrer">https://www.dropbox.com/s/k66xonom9up1yif/Country%20Search%20ListView.zip?dl=0</a>
  <br>
  Here my Sample code: <br><br>
  <strong>Search_Country.java</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>package com.nasir.search;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  
  import android.app.Activity;
  import android.app.ListActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.BaseAdapter;
  import android.widget.EditText;
  import android.widget.ListView;
  import android.widget.TextView;
  
  
  public class Search_Country extends ListActivity {
   
   private EditText SearchText;
   private ListView ListText;
   
   private String[] Number_List = {
    // Africa : North Africa
    "Algeria", "Egypt", "Libya", "Morocco", "Tunisia", "Western Sahara", 
  
    // Sub-Saharan Africa
    "Angola", "Benin", "Botswana", "Burkina Faso", "Burundi", "Cameroon", "Cape Verde", "Chad", "Comoros", "Congo", 
    "Côte d'Ivoire", "Djibouti", "Equatorial Guinea", "Eritrea", "Ethiopia", "Gabon", "Gambia", "Ghana", "Guinea", "Kenya",
    "Lesotho", "Liberia", "Madagascar", "Malawi", "Mali", "Mauritania", "Mauritius", "Mayotte", "Mozambique", "Namibia", 
    "Niger", "Nigeria", "Rwanda", "Senegal", "Seychelles", "Sierra Leone", "Somalia", "South Africa", "South Sudan", 
    "Sudan", "Swaziland", "Uganda", "Zambia", "Zimbabwe", 
    
    // Asia : 
    // East Asia
    "China", "Hong Kong", "Japan", "Korea", "Macao", "Mongolia", "Taiwan", 
    
    // North Asia
    "Belarus", "Moldova", "Russian Federation", "Ukraine", 
    
    // West &amp; Central Asia
    "Afghanistan", "Armenia", "Azerbaijan", "Bahrain", "Cyprus", "Georgia", "Iran", "Iraq", "Israel", "Jordan", "Kazakhstan",
    "Kuwait", "Kyrgyzstan", "Lebanon", "Oman", "Pakistan", "Qatar", "Saudi Arabia", "Tajikistan", "Turkey", "Turkmenistan", 
    "United Arab Emirates", "Uzbekistan", "Yemen", 
    
    // South &amp; Southeast Asia
    "Bangladesh", "Bhutan", "Brunei", "Cambodia", "India", "Indonesia", "Malaysia", "Maldives", "Myanmar", "Nepal", 
    "Philippines", "Singapore", "Sri Lanka", "Thailand", "Timor-Leste", "Viet Nam", 
    
    // Europe
    "Åland Islands", "Albania", "Andorra", "Austria", "Belgium", "Bosnia and Herzegovina", "Bulgaria", "Croatia", 
    "Czech Republic", "Denmark", "Estonia", "Faroe Islands", "Finland", "France", "Germany", "Gibraltar", "Greece", 
    "Greenland", "Guernsey", "Hungary", "Iceland", "", "", "", "", "Ireland", "Jersey", "Latvia", "Liechtenstein", 
    "Lithuania", "Luxembourg", "Macedonia", "Monaco", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", 
    "Romania", "San Marino", "Serbia", "Slovakia", "Slovenia", "Spain", "Svalbard and Jan Mayen", "Sweden", "Switzerland", 
    "United Kingdom", 
    
    // North &amp; Central America
    "Caribbean Islands", "Anguilla", "Antigua and Barbuda", "Aruba", "Bahamas", "Barbados", "Bermuda", "Cayman Islands", 
    "Bonaire", "Cuba", "Dominica", "Curaçao", "Guadeloupe", "Haiti", "Jamaica", "Martinique", "Montserrat", "Puerto Rico", 
    "Saint Bathélemy", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French Part)", "Saint Vincent and the Grenadines",
    "Sint Maarten (Dutch Part)", "Trinidad and Tobago", "Turks and Caicos Islands", "Virgin Islands, British", "Virgin Islands, U.S.",
    
    // Mesoamerica (or Central America)
    "Belize", "Costa Rica", "El Salvador", "Guatemala", "Honduras", "Mexico", "Nicaragua", "Panama",
    
    // North America
    "Canada", "Saint Pierre and Miquelon", "United States", 
  
    // Oceania
    "American Samoa", "Australia", "Christmas Island", "Cocos (Keeling) Islands", "Cook Islands", "Fiji", "Guam", "Kiribati",
    "Marshall Islands", "Micronesia", "New Caledonia", "New Zealand", "Niue", "Norfolk Island", "Northern Mariana Islands", 
    "Palau", "Papua New Guinea", "Pitcairn", "Samoa", "Solomon Islands", "Tokelau", "Tonga", "Tuvalu", "United States Minor Outlying Islands",
    "Vanuatu", "Wallis and Futuna", 
  
    // South America
    "Argentina", "Bolivia", "Brazil", "Chile", "Colombia", "Ecuador", "Falkland Islands (Malvinas)", "French Guiana", "Guyana",
    "Paraguay", "Peru", "Suriname", "Uruguay", "Venezuela"};
   
   private ArrayList&lt;String&gt; array_sort;
   int textlength = 0;
  
   public void onCreate(Bundle savedInstanceState) 
   {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_country);
  
    SearchText = (EditText) findViewById(R.id.listview_search);
    ListText = (ListView) findViewById(android.R.id.list);
  
    array_sort = new ArrayList&lt;String&gt;(Arrays.asList(Number_List));
    setListAdapter(new bsAdapter(this));
  
    SearchText.addTextChangedListener(new TextWatcher()
    {
     public void afterTextChanged(Editable s) 
     {
  
     }
  
     public void beforeTextChanged(CharSequence s, int start, int count, int after)
     {
  
     }
  
     public void onTextChanged(CharSequence s, int start, int before, int count)
     {
      textlength = SearchText.getText().length();
      array_sort.clear();
      for (int i = 0; i &lt; Number_List.length; i++) 
      {
       if (textlength &lt;= Number_List[i].length()) 
       {      
        if(Number_List[i].toUpperCase().contains(SearchText.getText().toString().toUpperCase().trim()))
        {
         array_sort.add(Number_List[i]);
        }
       }
      }
      AppendList(array_sort);
     }
    });
  
    ListText.setOnItemClickListener(new OnItemClickListener() 
    {
     public void onItemClick(AdapterView&lt;?&gt; parent, View view,
       int position, long id) {
      if( array_sort.get(position).equals("Afghanistan")){
          Intent intent = new Intent(Search_Country.this, Country_Details.class);                            
          intent.putExtra("header", getString(R.string.html_afganistan));                                       
          startActivity(intent);
      }
      else if ( array_sort.get(position).equals("Albania")){
       Intent intent = new Intent(Search_Country.this, Country_Details.class);
       intent.putExtra("header", getString(R.string.html_albenia));
       startActivity(intent);
      }
      
      else if ( array_sort.get(position).equals("Algeria")){
       Intent intent = new Intent(Search_Country.this, Country_Details.class);
       intent.putExtra("header", getString(R.string.html_algeria));
       startActivity(intent);
      }
      
      else if ( array_sort.get(position).equals("Brazil")){
       Intent intent = new Intent(Search_Country.this, Country_Details.class);
       intent.putExtra("header", getString(R.string.html_brazil));
       startActivity(intent);
      }
      
     }
    });
   }
  
   public void AppendList(ArrayList&lt;String&gt; str) 
   {
    setListAdapter(new bsAdapter(this));
   }
  
   public class bsAdapter extends BaseAdapter 
   {
    Activity cntx;
  
    public bsAdapter(Activity context) 
    {
     this.cntx = context;
    }
  
    public int getCount()
    {
     return array_sort.size();
    }
  
    public Object getItem(int position) 
    {
     return array_sort.get(position);
    }
  
    public long getItemId(int position)
    {
     return array_sort.size();
    }
  
    public View getView(final int position, View convertView, ViewGroup parent) 
    {
     View row = null;
     LayoutInflater inflater = cntx.getLayoutInflater();
     row = inflater.inflate(R.layout.search_country_listview, null);
     TextView tv = (TextView) row.findViewById(R.id.listview_seacrh_text);
     tv.setText(array_sort.get(position));
     return row;
    }
   }
  }</code></pre>
  </div>
  </div>
  </p>