2013-03-25 218 views

回答

0

您必须使用自定义列表视图Horizantal添加“负载更多”按钮。

0

一种替代和有点脏的解决方案是与特定的标记添加一个虚拟项目适配器的您的支持列表。在getView的帮助下检查这个虚拟物品的标志和充气页脚视图。

更新列表时一定要小心。您应该删除一个虚拟项目,并添加额外的列表,然后在需要

添加虚拟物品比方说这是你的列表项。

class Item { 
    String title; 
    String imageUrl; 
    boolean flagFooter;//this is the flag which will be set when the view is a dummy view 
} 

的getView方法可以是这个样子:

public View getView(int position, View convertView, ViewGroup parent) { 
    ViewHolder holder = null; 
    Item i = getItem(position); 
    //check whether a view needs to be inflated or not 
    if (convertView == null){ 
     holder = new ViewHolder(); 
     //check whether the view is the footer view or not 
     if(i.flagFooter){ 
      holder.flagFooter = true; 
      convertView = inflater.inflate(R.layout.list_footer, null); 
     }else{ 
      convertView = inflater.inflate(R.layout.list_row, null); 
     } 
     //assign holder views all findViewById goes here 

     convertView.setTag(holder); 
    }else{ 
     holder = (ViewHolder) convertView.getTag(); 
     //check whether the view is the footer view or not 
     if(i.flagFooter){ 
      holder.flagFooter = true; 
      convertView = inflater.inflate(R.layout.list_footer, null); 
      convertView.setTag(holder); 
     }else{ 
      //check if the view which is being reused is a footer view 
      //if it is footer view a list row view should be used. 
      if(holder.flagFooter){ 
       holder.flagFooter = false; 
       convertView = inflater.inflate(R.layout.list_row, null); 
       convertView.setTag(holder); 
      } 
     } 
    } 

    //update view here 
    return convertView; 

} 

的观点持有者

class ViewHolder{ 
    TextView title; 
    ImageView img; 
    boolean footer; 
} 

正如我之前提到的,这是做这项工作的一个肮脏的方式,但工程刚好的,以前用过这种方法。