Android 错误名称:类型yourActivity.ListAdapter的方法getFilter()未定义

Android 错误名称:类型yourActivity.ListAdapter的方法getFilter()未定义,android,Android,下面的代码显示了如何获取列表数据以及如何显示列表数据。 如果需要的话,请小心别离开它 public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } public void afterTextChanged(Editab

下面的代码显示了如何获取列表数据以及如何显示列表数据。 如果需要的话,请小心别离开它

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                int arg3) {
            // TODO Auto-generated method stub

        }

        public void afterTextChanged(Editable arg0) {
            // TODO Auto-generated method stub
        }
    });
公共列表getFriendsList(){ 字符串accessToken=null; DatabaseHelper=新的DatabaseHelper(getApplicationContext()); DatabaseUtility dao=新的DatabaseUtility(助手); 试一试{ accessToken=dao.getAccessToken(); }捕获(异常e1){ handler.sendEmptyMessage(1); 返回null; } if(accessToken==null | | accessToken.length()==0){ handler.sendEmptyMessage(1); 返回null; } Map params=新的HashMap(); 参数put(常数.ACCESS_TOKEN_PARAM,accessToken); 列表friendsList=null; 试一试{ friendsList=Utils.getFriendsList(参数,this); }捕获(NullPointerException e){ handler.sendEmptyMessage(12); 返回null; }捕获(JSONException e){ //handler.sendEmptyMessage(11); 返回null; } 回报友人名单; } public void displayFriends(列出好友列表){ 列表好友列表=好友列表; availableFriends=新的ArrayList(); HashMap friendData=null; Friend=null; 试一试{ 对于(int i=0;i<代码> >代码> ListAdabor < /Cord>不实现接口。然而,一些适配器,如DO和DO。这意味着您应该考虑将适配器转换为实现接口的东西,或者制作自己的自定义适配器并在其中实现。
另外,根据上面的代码,您将
适配器设置为null,并且不初始化它(我没有看到调用
displayFriends()
。您还应该检查一下,以确保您的初始化是正确的(当然,在选择更合适的适配器之后).

我想为listadapter实现过滤功能,那么我该怎么做呢?您必须创建一个单独的类,扩展listadapter
,并使其实现
可过滤
,从那里您就实现了该方法。我自己还没有实际使用过该方法,因此我不知道实现的全部细节ion.SO问题给出了一种示例和答案。@srilatha不,谢谢,我将坚持stackoverflow。您可能还应该从您的评论中删除链接(您可以编辑您的评论)。无论如何,我建议你尝试一下,做一些研究,一旦你有具体的问题就回来。好的,谢谢你的时间,我没有要点来支持你的答案,谢谢你的时间,残疾人链接从现在起就不起作用了。
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                int arg3) {
            // TODO Auto-generated method stub

        }

        public void afterTextChanged(Editable arg0) {
            // TODO Auto-generated method stub
        }
    });
public List<Friend> getFriendsList(){
    String accessToken = null;
    DatabaseHelper helper = new DatabaseHelper(getApplicationContext());
    DatabaseUtility dao = new DatabaseUtility(helper);
    try {
        accessToken = dao.getAccessToken();
    } catch (Exception e1) {
        handler.sendEmptyMessage(1);
        return null;
    }
    if(accessToken == null || accessToken.length() == 0){
        handler.sendEmptyMessage(1);
        return null;
    }

    Map<String , String> params = new HashMap<String,String>();
    params.put(Constants.ACCESS_TOKEN_PARAM, accessToken);

    List<Friend> friendsList = null;
    try {
            friendsList = Utils.getFriendsList(params,this);
    } catch (NullPointerException e) {
        handler.sendEmptyMessage(12);
        return null;
    } catch (JSONException e) {
        //handler.sendEmptyMessage(11);
        return null;
    }
    return friendsList;
}

public void displayFriends(List<Friend> friendList){
    List<Friend> friendsList = friendList;
    availableFriends = new ArrayList<HashMap<String,Object>>();
    HashMap<String, Object> friendData = null;
    Friend friend = null;
    try{
        for(int i = 0 ; i < friendsList.size() ; i++){
            friend = friendsList.get(i);
            friendData = new HashMap<String, Object>();
            friendData.put(FRIENDS_NAME_KEY, friend.getFriendName());
            friendData.put(IS_IMAGE_KEY, friend.getIsImage());
            friendData.put(IDKEY, friend.getFriendID());
            availableFriends.add(friendData);
        }

    adapter = new ListAdapter(availableFriends,FriendsActivity.this);
    listView.setAdapter(adapter);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);