title: Play specific sound on list item click
body: <p>I have this app where I have a listview and I would like to play a sound when an item is clicked. I tried a lot of things but none of them seem to solve my problem. </p>
  
  <p>It's a listview with words, it's translation and a play button, when I click the button I want to play the sound of the specific word. Here I have my adapter and the class used. If someone knows how to answer this question I would be happy ;)</p>
  
  <p>CLASS:</p>
  
  <pre><code>public class VB_Itens extends ListActivity {
          private VB_Itens_Adapter adapter;
          private int wordsArrayId, translationsArrayId;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
  
              int position = getIntent().getIntExtra("position", 0);
  
              // Here i populate the list with the words and it's translations from arrays resource
  
              switch (position) {
  
              case 0:
                  wordsArrayId = R.array.VB_airport_words;
                  translationsArrayId = R.array.VB_airport_translations;
                  break;
              case 1:
                  wordsArrayId = R.array.VB_hotel_words;
                  translationsArrayId = R.array.VB_hotel_translations;
                  break;
              case 2:
                  wordsArrayId = R.array.VB_hospital_words;
                  translationsArrayId = R.array.VB_hospital_translations;
                  break;
              case 3:
                  wordsArrayId = R.array.VB_restaurant_words;
                  translationsArrayId = R.array.VB_restaurant_translations;
                  break;
              }
  
              adapter = new VB_Itens_Adapter(this, wordsArrayId, translationsArrayId);
              setListAdapter(adapter);
          }
  
          @Override
          protected void onListItemClick(ListView l, View v, int position, long id) {
  
              // I want to play a specific sound and the item is clicked
              // I don't know how to take these sounds
  
          }
      }
  </code></pre>
  
  <p>ADAPTER:</p>
  
  <pre><code>public class VB_Itens_Adapter extends BaseAdapter {
  
      private List&lt;Palavra&gt; listaPalavras = new ArrayList&lt;Palavra&gt;();
      private LayoutInflater inflater;
  
      public VB_Itens_Adapter(Context context, int resPalavra, int resTraducao) {
          inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          String palavras[] = context.getResources().getStringArray(resPalavra);
          String traducoes[] = context.getResources().getStringArray(resTraducao);
  
          for (int i = 0; i &lt; palavras.length; i++) {
              Palavra palavra = new Palavra(palavras[i], traducoes[i]);
              listaPalavras.add(palavra);
          }
      }
  
      @Override
      public int getCount() {
          return listaPalavras.size();
      }
  
      @Override
      public Object getItem(int position) {
          return listaPalavras.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return 0;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view = inflater.inflate(R.layout.vb_itens, null);
  
          Palavra palavra = listaPalavras.get(position);
  
          TextView palavraView = (TextView) view.findViewById(R.id.palavra);
          TextView traducaoView = (TextView) view.findViewById(R.id.traducao);
  
          palavraView.setText(palavra.getPalavra());
          traducaoView.setText(palavra.getTradução());
  
          return view;
      }
  }
  </code></pre>