premise: i'm newbie on Java and Android, and i've search a lot for this but i don't understand how implement getFilter in my code.
this is MainActivity (relevant code):
public void loadList() {
/* allProd and allSpec are ArrayList<String> */
String[] allProdString = allProd.toArray(new String[allProd.size()]);
String[] allSpecString = allSpec.toArray(new String[allSpec.size()]);
listViewAdapter = new ListViewAdapter(this, allProdString, allSpecString);
listView.setAdapter(listViewAdapter);
}
this is customAdapter:
public class ListViewAdapter extends BaseAdapter {
Activity context;
String title[];
String description[];
public ListViewAdapter(Activity context, String[] title, String[] description) {
super();
this.context = context;
this.title = title;
this.description = description;
}
public int getCount() {
return title.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
private class ViewHolder {
TextView txtViewTitle;
TextView txtViewDescription;
}
public View getView(int position, View convertView, ViewGroup parent) {
Typeface typeface = Typeface.createFromAsset(context.getAssets(), "font/Simple_Print.ttf");
ViewHolder holder;
LayoutInflater inflater = context.getLayoutInflater();
if (convertView == null) {
convertView = inflater.inflate(R.layout.tabella_prodotti, null);
holder = new ViewHolder();
holder.txtViewTitle = (TextView) convertView.findViewById(R.id.titoloProd);
holder.txtViewDescription = (TextView) convertView.findViewById(R.id.subtitoloProd);
holder.txtViewDescription.setTypeface(typeface);
holder.txtViewTitle.setTypeface(typeface);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
holder.txtViewTitle.setText(title [position]);
holder.txtViewDescription.setText(description [position]);
return convertView;
}
}
how can I implement this function to have the ability to search within an array, and show the filtered results in the listview?
if you need any other info just ask! thanks