2012/03/25

[Android] Gridview display in reverse order

If your Gridview got a reverse order display bug after refresh the screen
try to change the code of Google sample to below code
 public View getView(int position, View convertView, ViewGroup parent) { 
     View v = convertView; 
     if(convertView==null){ 
         LayoutInflater li = getLayoutInflater(); 
         v = li.inflate(R.layout.iconview, parent, false); 
     } 
     TextView tv = (TextView)v.findViewById(R.id.icon_text); 
     tv.setText(fun_strs[position]); 
     ImageView iv = (ImageView)v.findViewById(R.id.icon_image); 
     iv.setImageResource(fun_imgs[position]); 
     return v; 
 }

沒有留言: