Custom listview contains imagebutton,play sound when button is click
<p>I have custom Lisview containing textview and imagebutton...i want to play specific audio file for every button in a row.the audio files are in raw folder,how can i do this?</p>

<pre><code>MainActivity.java
public class MainActivity extends Activity {
ListViewAdapter adapter;
ArrayList&lt;DictionaryApp&gt; arrayList = new ArrayList();
String[] cuyuno;
String[] edefinition;
EditText editsearch;
String[] english;
ListView list;
int[] sound;
String[] tagalog;
String[] tbaybay;
String[] tdefinition;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.tagalog = new String[]{"alaala", "araw", "baliw", "basura", "kahirapan", "kaibigan", "kakatuwa", "kasunduan", "daluyang-luha", "dambuhala", "dulo", "dukutin", "gawin", "guni-guni", "hagdan", "hintay", "idlip", "idolo", "maganda", "masama", "masarap", "matalino", "nagtanan", "nawala", "pagbibitiw", "paikliin"};
    this.tbaybay = getResources().getStringArray(R.array.tbaybay);
    this.tdefinition = getResources().getStringArray(R.array.tdefinition);
    this.cuyuno = getResources().getStringArray(R.array.cuyuno);
    this.english = getResources().getStringArray(R.array.eword);
    this.edefinition = getResources().getStringArray(R.array.edefinition);
    this.sound = new int[]{R.raw.alaala, R.raw.araw, R.raw.baliw, R.raw.basura, R.raw.kaibigan, R.raw.kakatuwa, R.raw.kasunduan};
    this.list = (ListView) findViewById(R.id.listview);
    for (int i = 0; i &lt; this.tagalog.length; i++) {
        this.arrayList.add(new DictionaryApp(this.tagalog[i], this.tbaybay[i], this.tdefinition[i], this.cuyuno[i], this.english[i], this.edefinition[i]));
    }
    this.adapter = new ListViewAdapter(this, this.arrayList);
    this.list.setAdapter(this.adapter);
    this.editsearch = (EditText) findViewById(R.id.search);
    this.editsearch.addTextChangedListener(new TextWatcher() {
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        public void afterTextChanged(Editable arg0) {
            MainActivity.this.adapter.filter(MainActivity.this.editsearch.getText().toString().toLowerCase(Locale.getDefault()));
        }
    });
}
}



ListViewAdapter.java
public class ListViewAdapter extends BaseAdapter {
private ArrayList&lt;DictionaryApp&gt; arraylist;
private List&lt;DictionaryApp&gt; dictionaryapplist = null;
LayoutInflater inflater;
Context mContext;

public class ViewHolder {
    TextView cuyuno;
    TextView edefinition;
    TextView english;
    ImageButton sound;
    TextView tagalog;
    TextView tbaybay;
    TextView tdefinition;
}

public ListViewAdapter(Context context, List&lt;DictionaryApp&gt; dictionaryapplist) {
    this.mContext = context;
    this.dictionaryapplist = dictionaryapplist;
    this.inflater = LayoutInflater.from(this.mContext);
    this.arraylist = new ArrayList();
    this.arraylist.addAll(dictionaryapplist);
}

public int getCount() {
    return this.dictionaryapplist.size();
}

public DictionaryApp getItem(int position) {
    return (DictionaryApp) this.dictionaryapplist.get(position);
}

public long getItemId(int position) {
    return (long) position;
}

public View getView(final int position, View view, ViewGroup parent) {
    ViewHolder holder;
    if (view == null) {
        holder = new ViewHolder();
        view = this.inflater.inflate(R.layout.listview_item, null);
        holder.tagalog = (TextView) view.findViewById(R.id.tagalog);
        holder.tbaybay = (TextView) view.findViewById(R.id.tbaybay);
        holder.tdefinition = (TextView) view.findViewById(R.id.tdefinition);
        holder.cuyuno = (TextView) view.findViewById(R.id.cuyuno);
        holder.english = (TextView) view.findViewById(R.id.english);
        holder.edefinition = (TextView) view.findViewById(R.id.edefinition);
        holder.sound = (ImageButton) view.findViewById(R.id.sound);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }
    holder.tagalog.setText(((DictionaryApp) this.dictionaryapplist.get(position)).getTagalog());
    holder.tbaybay.setText(((DictionaryApp) this.dictionaryapplist.get(position)).getTbaybay());
    holder.tdefinition.setText(((DictionaryApp) this.dictionaryapplist.get(position)).getTdefinition());
    holder.cuyuno.setText(((DictionaryApp) this.dictionaryapplist.get(position)).getCuyuno());
    holder.english.setText(((DictionaryApp) this.dictionaryapplist.get(position)).getEnglish());
    holder.edefinition.setText(((DictionaryApp) this.dictionaryapplist.get(position)).getEdefinition());

    view.setOnClickListener(new OnClickListener() {
        public void onClick(View arg0) {
            Intent intent = new Intent(ListViewAdapter.this.mContext, SingleItemView.class);
            intent.putExtra("tagalog", ((DictionaryApp) ListViewAdapter.this.dictionaryapplist.get(position)).getTagalog());
            intent.putExtra("tbaybay", ((DictionaryApp) ListViewAdapter.this.dictionaryapplist.get(position)).getTbaybay());
            intent.putExtra("tdefinition", ((DictionaryApp) ListViewAdapter.this.dictionaryapplist.get(position)).getTdefinition());
            intent.putExtra("cuyuno", ((DictionaryApp) ListViewAdapter.this.dictionaryapplist.get(position)).getCuyuno());
            intent.putExtra("english", ((DictionaryApp) ListViewAdapter.this.dictionaryapplist.get(position)).getEnglish());
            intent.putExtra("edefinition", ((DictionaryApp) ListViewAdapter.this.dictionaryapplist.get(position)).getEdefinition());
            ListViewAdapter.this.mContext.startActivity(intent);
        }
    });
    return view;
}

public void filter(String charText) {
    charText = charText.toLowerCase(Locale.getDefault());
    this.dictionaryapplist.clear();
    if (charText.length() == 0) {
        this.dictionaryapplist.addAll(this.arraylist);
    } else {
        Iterator i$ = this.arraylist.iterator();
        while (i$.hasNext()) {
            DictionaryApp da = (DictionaryApp) i$.next();
            if (da.getTagalog().toLowerCase(Locale.getDefault()).contains(charText)) {
                this.dictionaryapplist.add(da);
            }
        }
    }
    notifyDataSetChanged();
}
}


DictionaryApp.java
public class DictionaryApp {
private String cuyuno;
private String edefinition;
private String english;
private String tagalog;
private String tbaybay;
private String tdefinition;

public DictionaryApp(String tagalog, String tbaybay, String tdefinition, String cuyuno, String english, String edefinition) {
    this.tagalog = tagalog;
    this.tbaybay = tbaybay;
    this.tdefinition = tdefinition;
    this.cuyuno = cuyuno;
    this.english = english;
    this.edefinition = edefinition;
}

public String getTagalog() {
    return this.tagalog;
}

public String getTbaybay() {
    return this.tbaybay;
}

public String getTdefinition() {
    return this.tdefinition;
}

public String getCuyuno() {
    return this.cuyuno;
}

public String getEnglish() {
    return this.english;
}

public String getEdefinition() {
    return this.edefinition;
}   

}
</code></pre>

<p>The audio files are in raw folder,what i want to come out is that the audio will play in the imagebutton inside the listview....i am newbie in android, help is what i appreciate the most...thanks</p>