how to assign query to GridItem in SearchView? <p>I am trying to create a SearchView that searches for GridItems that each launch a specific second activity. However I cannot figure out the code that will help me with this. I have already set an onQueryTextChangeListener for the SearchView which should allow me to show results manually and whilst typing. Here's what I want to happen:</p> <p>When I type a specific query, let's say "car", I want to show the GridItem (which is just a clickable ImageView) of a car to the user. When I type "Camera", I want to show the user my GridItem with the image of a Camera on it.</p> <p>I also want to display results to the user whilst typing, so when I have only typed "c" yet, I want to show the user both the "car" and "Camera" GridItems. I want to stay in the same activity, so I need some sort of way to delete all GridItems except for the ones with a camera or a car picture on it depending on what the user typed, I don't want to launch a search activity.</p> <p>Now what makes this just a little harder is that I configured my BaseAdapter in a separate class, which means that I have to indirectly mention the GridItems in some way. Here's what I've done so far:</p> <pre><code> @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); final MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (query.equals(R.string.Coconut)){ //here I need some code that will tell the system that I want to show the GridItem with a picture of a coconut on it } return false; } @Override public boolean onQueryTextChange(String newText) { return false; } </code></pre> <p>This is the separate class that initialises the Images in the GridView:</p> <pre><code>class SingleItem{ int image; double nutritional_value; SingleItem(int image, double nutritional_value){ this.image = image; this.nutritional_value = nutritional_value; } } public class objectAdapter extends BaseAdapter { ArrayList&lt;SingleItem&gt; list; Context context; Bundle myBundle; objectAdapter(Context context) { this.context = context; myBundle = new Bundle(); double[][] nutritional_value = { {89, 22.8, 0.3, 1}, {61, 1.5, 0.5, 1.1}, {375, 6.8, 0.6, 1.2}, {767, 0, 9.3, 0}, {580, 9.1, 42, 36.5} }; myBundle.putSerializable("array_array", nutritional_value); int[] image_id = { R.drawable.Bananas, R.drawable.Kiwis, R.drawable.oatmeals, R.drawable.coconuts, R.drawable.dark_chocolate }; for (int i = 0; i &lt; image_id.length; i++) { SingleItem tempSingleItem = new SingleItem(image_id[i], nutritional_value[i][i]); list.add(tempSingleItem); } } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; ViewHolder holder = null; if (row == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.single_item, parent, false); holder= new ViewHolder(row); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } SingleItem temp = list.get(position); holder.myItem.setImageResource(temp.image); holder.myItem.setTag(temp); return row; } @Override public long getItemId(int position) { return position; } class ViewHolder { ImageView myItem; ViewHolder(View v){ myItem = (ImageView) v.findViewById(R.id.imageView2); } } @Override public Object getItem(int position) { return list.get(position); } @Override public int getCount() { return list.size(); } } </code></pre> <p>Thanks in advance!</p> <p>Vidal</p>