title: Select item from spinner, filter/sort results from JSON in ListView
body: <p>I have a listview from json which is the following:</p>
  
  <pre><code>{
  "GetPOIByTypeResult": [
      {
          "ID": 1,
          "Name": "Spitalul Judetean",
          "Phone": "085228291",
          "Rating": 44,
          "Schedule": {
              "ClosingHour": 16,
              "ID": 1,
              "IsNonStop": false,
              "IsOpenOnFriday": true,
              "IsOpenOnMonday": true,
              "IsOpenOnSaturday": false,
              "IsOpenOnSunday": false,
              "IsOpenOnThursday": true,
              "IsOpenOnTuesday": true,
              "IsOpenOnWednesday": true,
              "Name": "Monday to Friday",
              "OpenHour": 8
          },
          "Specialities": [
              {
                  "ID": 1,
                  "Name": "Stomatologie"
              },
              {
                  "ID": 2,
                  "Name": "Radiologie"
              },
              {
                  "ID": 3,
                  "Name": "Cardiologie"
              },
              {
                  "ID": 4,
                  "Name": "Ginecologie"
              },
              {
                  "ID": 5,
                  "Name": "Pediatrie"
              },
              {
                  "ID": 6,
                  "Name": "Patologie"
              },
              {
                  "ID": 7,
                  "Name": "Oncologie"
              },
              {
                  "ID": 8,
                  "Name": "Macelarie"
              },
              {
                  "ID": 9,
                  "Name": "Oftalmologie"
              },
              {
                  "ID": 10,
                  "Name": "Ghipsologie"
              }
          ],
          "Type": "Hospital"
      },
  
  ]
  }
  </code></pre>
  
  <p>In my listview, there are results from the field: "Name".
  I want to filter my list by Specialities which is not displayed in the list, only returns the value.
  I have actually no idea how to make this work, this is what I have done so far:</p>
  
  <pre><code>package com.example.medical.map;
  
  import java.util.ArrayList;
  
  public class SearchActivityHospitals extends ListActivity {
  
  Button searchButton;
  Button closeButton;
  public Spinner spinner1;
  private String poiType[];
  private boolean isSearch = false;
  EditText editText, editText2;
  JsonArrayAdapterHospitals adapter;
  ArrayList&lt;Hospitals&gt; tempName = new ArrayList&lt;Hospitals&gt;();
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.search_activity_layout_actionbar_hospitals);
      adapter = new JsonArrayAdapterHospitals(this, tempName);
      setListAdapter(adapter);
  
      poiType = new String[] {"", "Stomatologie", "Radiologie", "Cardiologie", "Ginecologie", "Pediatrie", "Patologie", "Oncologie", "Macelarie", "Oftalmologie", "Ghipsologie"};
      //this is my spinner
      ArrayAdapter&lt;String&gt; adapter0 = new ArrayAdapter&lt;String&gt;(SearchActivityHospitals.this, android.R.layout.simple_spinner_item, poiType);
      adapter0.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
  
      spinner1.findViewById(R.id.spinnerSpecialityHospitals);
      spinner1.setAdapter(adapter0);
      spinner1.setOnItemSelectedListener(new MyOnItemSelectedListener()
      );
  
      WebService.setOnFinishAllHospitals(new OnFinishAllHospitals() {
  
          public void onFinishAllHospitals(ArrayList&lt;Hospitals&gt; hospitals) {
  
              if (hospitals != null) {
                  if (hospitals.size() &gt; 0) {
                      tempName.clear();
                      tempName.addAll(hospitals);
                      adapter.notifyDataSetChanged();
                  }
  
              }
  
          }
  
      });
  
      WebService
              .GetPOIByType("http://82.77.55.81:9090/MedicalMap/MedicalMap.svc/Getpoibytype/hospital");
  
      final ListView lv = getListView();
      lv.setTextFilterEnabled(true);
      lv.setOnItemClickListener(new OnItemClickListener() {
  
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                  int position, long id) {
  
              Intent intent = new Intent(SearchActivityHospitals.this, DetailsHospitals.class);
              intent.putExtra("Value", tempName.get(position));
              startActivity(intent);
  
          }
      });
  
      editText = (EditText) findViewById(R.id.editNameTextHospitals);
      editText.addTextChangedListener(new TextWatcher() {
  
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
          }
  
          public void onTextChanged(CharSequence s, int start, int before,
                  int count) {
              adapter.getFilter().filter(s); // Filter from my adapter
              adapter.notifyDataSetChanged(); // Update my view
          }
  
          public void afterTextChanged(Editable s) {
  
          }
  
      });
  
      editText2 = (EditText) findViewById(R.id.editAddressTextHospitals);
      editText2.addTextChangedListener(new TextWatcher() {
  
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
          }
  
          public void onTextChanged(CharSequence s, int start, int before,
                  int count) {
              adapter.getFilter().filter(s); // Filter from my adapter
              adapter.notifyDataSetChanged(); // Update my view
          }
  
          public void afterTextChanged(Editable s) {
  
          }
  
      });
  
  
  
  }
  //and here is my onitem click listener which I have no idea how to do, please help
  public class MyOnItemSelectedListener implements OnItemSelectedListener{
  
      public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position,
              long id) {
          if(spinner1.getSelectedItem().equals("Stomatologie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Radiologie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Cardiologie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Ginecologie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Pediatrie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Patologie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Oncologie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Macelarie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Oftalmologie")){
  
          }else{
  
          }
          if(spinner1.getSelectedItem().equals("Ghipsologie")){
  
          }else{
  
          }
  
      }
  
  
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          spinner1.getSelectedItem().equals("");
          {
  
          }
      }
  
  
  
  public void handleClick_search(View v) {
  
      ImageView searchButton = (ImageView) findViewById(R.id.searchButton);
      searchButton.setVisibility(View.INVISIBLE);
      LinearLayout layout = (LinearLayout) findViewById(R.id.searchFieldLayout);
      layout.setVisibility(View.VISIBLE);
  
  }
  
  public void handleClick_closeSearch(View v) {
  
      ImageView searchButton = (ImageView) findViewById(R.id.searchButton);
      searchButton.setVisibility(View.VISIBLE);
      LinearLayout layout = (LinearLayout) findViewById(R.id.searchFieldLayout);
      layout.setVisibility(View.GONE);
  
  }
  
  public void showSearch() {
  
      if (isSearch != true) {
          isSearch = true;
          searchButton.setVisibility(View.INVISIBLE);
          closeButton.setVisibility(View.VISIBLE);
          findViewById(R.layout.search_activity_layout_doctors).setVisibility(View.VISIBLE);
  
      }
  
  }
  
  public void hideSearch() {
      if (isSearch != false) {
          isSearch = false;
          searchButton.setVisibility(View.VISIBLE);
          closeButton.setVisibility(View.GONE);
          findViewById(R.layout.search_activity_layout_doctors).setVisibility(View.GONE);
  
      }
  
  }
  
  
  }
  }
  </code></pre>
  
  <p>So my question is, how to make the following:
  Select item from spinner -> filter/sort list by selected criteria
  Criteria is parsed but not shown in list so the data is there but how to do it?</p>