title: How to use switch case with string resources
body: <p>How can I use the switch case scenario with string resources rather than hard coded names? My strings are exactly the same names used for the spellings of them.</p>
  
  <pre><code>        @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              MainListAdapter adapter = (MainListAdapter) parent.getAdapter();
              Main continent = adapter.getItem(position);
                 if (mTwoPane) {
                      View rowView = view;
                      setItemSelected(continent, rowView);
  
                      Fragment newFragment;
                      switch (stringRes) {
                          case R.id.africa:
                              newFragment = new FragmentAfrica();
                              break;
                          case R.id.asia:
                              newFragment = new FragmentAsia();
                              break;
                          case R.id.europe:
                              newFragment = new FragmentEurope();
                              break;
                          default:
                              newFragment = new FragmentAfrica();
                      }
  
                      MainActivity activity = (MainActivity) view.getContext();
                      FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
                      transaction.replace(R.id.detail_container, newFragment);
                      transaction.commit();
                  } else {
                }
  </code></pre>