【发布时间】:2014-06-17 10:34:12
【问题描述】:
我想在我的 Listview 上创建搜索功能,在我的列表中它包括 listview 图像、listview 标题和 listview 描述,但我想在标题和描述上应用搜索功能而不是在图像上,这怎么可能? 纠正我,如果我错了......我的适配器和搜索代码如下:
ArrayAdapter<String> adapter;
adapter = new ArrayAdapter(this, R.layout.single_row_fellow_student,
R.id.textView1, studentTitles) ;
list.setAdapter(adapter);
// Enabling Search Filter
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
MyFellowStudent.this.adapter.getFilter().filter(cs);
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
class StudentAdapter extends ArrayAdapter<String>
{
Context context;
String[] titleArray;
String[] descriptionArray;
int[] images;
StudentAdapter(Context c, String[] titles , int[] imgs , String[] desc) {
super(c, R.layout.single_row_fellow_student, R.id.textView1, titles );
this.context = c;
this.images = imgs;
this.titleArray = titles;
this.descriptionArray = desc;
}
【问题讨论】: