Özel Lisview, textview ve imagebutton içerir ... Bir satırdaki her düğme için belirli bir ses dosyasını çalmak istiyorum. Ses dosyaları ham klasörde, nasıl Bunu yap? Özel liste görünümü, imagebutton'u içeriyorsa, düğme tıklatıldığında sesi çaldır
MainActivity.java
public class MainActivity extends Activity {
ListViewAdapter adapter;
ArrayList<DictionaryApp> 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 < 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<DictionaryApp> arraylist;
private List<DictionaryApp> 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<DictionaryApp> 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;
}
}
ses dosyaları
ne ben gelmek istediğinde ses i android içinde deneyimsizim .... liste görünümü içindeki imagebutton oynayacağı yani ham klasörde, yardım i en takdir şeydir ... teşekkürler
Yukarıdaki kodla ilgili hata/sorun nedir? Doğrudan sorununuzu bunun yerine tüm ana sorunu gönderin. – MKJParekh
Sanırım cevabı burada okumalısınız [nasıl-müzikte-müzik-içinde-müzik-içinde-müzik-müzik-çalar] (http://stackoverflow.com/a/23227939/3832212) –
öneri yardımcı olabilir, ancak ana etkinlik sınıfında veya ListViewAdapter Sınıfında yer almalı mıyım? –