我是android的新手.
我的自定义适配器在过滤时导致异常
这是我的代码.private class DeptAdapter extends ArrayAdapter implements Filterable {
private ArrayList<Dept> items;
private ArrayList<Dept> mOriginalValues;
public DeptAdapter(Context context, int textViewResourceId, ArrayList<Dept> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.item_listview_2line, null);
}
Dept d = items.get(position);
if (d != null) {
TextView tt = (TextView) v.findViewById(R.id.toptext);
TextView bt = (TextView) v.findViewById(R.id.bottomtext);
if (tt …Run Code Online (Sandbox Code Playgroud) 我有一个带有搜索栏的列表视图,我想在编辑文本中键入文本时对项目进行排序.我一直试图这样做,但是无法完成,你能帮我做吗?我要感谢你提前感谢
我想实现getFilter()我的功能ListView,但每次我输入的东西EditText我ListView就会消失.
我的SetHelpRows档案:
public class SetHelpRows {
String name;
String id;
public String getName () {
return name;
}
public void setName (String name) {
this.name = name;
}
public String getID () {
return id;
}
public void setID (String id) {
this.id = id;
}
public SetHelpRows(String name, String id) {
super();
this.name = name;
this.id = id;
}
}
Run Code Online (Sandbox Code Playgroud)
我的SetHelpRowsCustomAdapter档案:
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context; …Run Code Online (Sandbox Code Playgroud)