Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 0.63 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Is it possible to use view inflator to inflate individual items?
  2. public View getView(int position,View v,ViewGroup parent) {
  3.     if (v == null) {
  4.         v = li.inflate(R.layout.grid_item,null);
  5.  
  6.         final TextView tv = (TextView) v.findViewById(R.id.grid_text);
  7.         tv.setText(String.valueOf(position+1));
  8.     }
  9.        
  10. if (v == null) {
  11.     if(position < 5){//whatever condition you want here    
  12.         v = li.inflate(R.layout.grid_item,null);
  13.     }
  14.     else{
  15.         v = li.inflate(R.layout.grid_item2,null);
  16.     }
  17. }
  18.  
  19. final TextView tv = (TextView) v.findViewById(R.id.grid_text);
  20. tv.setText(String.valueOf(position+1));
  21.        
  22. or