title: How do I implement SearchView with no errors
body: <p>I am a beginner and new to coding. I have a problem with ListView in Android Studio. I have created a simple activity with a simple Listview. The Listview contains locations, and when the user clicks on an item the app will open google maps and takes the user to that location. The problem occurred when I implemented a SearchView. When search is applied, whatever result is filtered it will always open the first location. So could you please help me with that. Thanks.
  This is my code and sorry for the mess.</p>
  <pre><code>MainActivity.java
  
  import com.example.myapplicationsecond.R;
  
  public class MainActivity9 extends AppCompatActivity {
  
      ListView listView;
      String[] name = {&quot;First Location&quot;,&quot;Second Location&quot;,&quot;Third Location&quot;,&quot;Fourth Location&quot;,};
  
      ArrayAdapter&lt;String&gt; arrayAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main9);
  
          View view = getLayoutInflater().inflate(R.layout.abs_layout, null);
          ActionBar.LayoutParams params = new ActionBar.LayoutParams(
                  ActionBar.LayoutParams.WRAP_CONTENT,
                  ActionBar.LayoutParams.MATCH_PARENT,
                  Gravity.CENTER);
  
          TextView Title = (TextView) view.findViewById(R.id.actionbar_title);
          Title.setText(&quot;Search Here&quot;);
  
          getSupportActionBar().setCustomView(view,params);
          getSupportActionBar().setDisplayShowCustomEnabled(true); //show custom title
          getSupportActionBar().setDisplayShowTitleEnabled(false); //hide the default title
  
  
          getSupportActionBar().setTitle(&quot;Search Here&quot;);
  
  
          listView = findViewById(R.id.listview);
  
          arrayAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,name);
          listView.setAdapter(arrayAdapter);
  
  
          listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  if(position==0){
  
                      Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(&quot;geo: 21.422458, 39.826213&quot;));
                      startActivity(intent);
  
                  }
                  if(position==1){
  
                      Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(&quot;geo: 24.467275, 39.610629&quot;));
                      startActivity(intent);
  
                  }
                  if(position==2){
  
                      Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(&quot;geo: 25.173059, 45.142079&quot;));
                      startActivity(intent);
  
                  }
                  if(position==3){
  
                      Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(&quot;geo: 26.348400, 43.766664&quot;));
                      startActivity(intent);
  
  
              }
  
              }
  
          });
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
  
  
          getMenuInflater().inflate(R.menu.menu,menu);
  
  
          MenuItem menuItem = menu.findItem(R.id.action_search);
          SearchView searchView = (SearchView) menuItem.getActionView();
          searchView.setQueryHint(&quot;Search Here&quot;);
  
          searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
              @Override
              public boolean onQueryTextSubmit(String query) {
                  return false;
              }
  
              @Override
              public boolean onQueryTextChange(String newText) {
  
  
                  arrayAdapter.getFilter().filter(newText);
  
  
  
                  return false;
              }
          });
  
          return super.onCreateOptionsMenu(menu);
      }
  
  
  
  
  }
  
  
  MainActivity.Xml
  
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.MainActivity9&quot;&gt;
  
  
      &lt;ListView
          android:id=&quot;@+id/listview&quot;
          android:textDirection=&quot;locale&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>