2013-03-25 78 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; 
} 

正如我之前提到的,這是做這項工作的一個骯髒的方式,但工程剛好的,以前用過這種方法。