Problem Description:
Before writing, the problem of the map, the problem, such as the GridView first item of the custom height display is not normal (again loaded and normal), not a preset height:
650) this.width=650; "style=" WIDTH:247PX;HEIGHT:377PX; "title=" QQ picture 20150915140447.png "alt=" Wkiol1x3t03buqyqaadxrxtwmys462.jpg "src=" http://s3.51cto.com/wyfs02/M02/73/32/ Wkiol1x3t03buqyqaadxrxtwmys462.jpg "width=" 345 "height=" 550 "/>
Workaround:
The first thing to declare, this GridView adapter is baseadapter, in the definition of the adapter GetView method, the main attention to the code/***********/markup Place, the following paste my GetView method:
Public view getview (int position, view convertview, viewgroup parent) { girdholder holder; if (ConvertView == null) { holder = new girdholder (); Convertview = layoutinflater.from (Getapplication ()). Inflate (R.layout.gridview_item, null); //set item ' S height gridview.layoutparams param = new gridview.layoutparams ( android.view.viewgroup.layoutparams.match_parent, ( Gvlist.getheight ()-(1+level) *16)/level); convertview.setlayoutparams (param); holder.imgView = (ImageView) convertview.findviewbyid (r.id.image); &nbSp; convertview.settag (holder); }else{ holder = ( Girdholder) convertview.gettag (); //fix the problem of first item ' s height is not normal /****************** Be sure to write the height code again in this position ******************************/ convertview.setlayoutparams (new Gridview.layoutparams ( android.view.viewgroup.layoutparams.match_parent, (Gvlist.getheight ()-(1+level) *16)/ Level)); /************************************************/ } if (status[position] == 0) { Holder.imgView.setImageResource (R.drawable.smile_yellow); }else{ Holder.imgView.setImageResource (R.drawable.smile_bule); } return convertview; }
And then post the solution:
650) this.width=650; "style=" width:261px;height:393px; "title=" QQ picture 20150915141517.png "alt=" Wkiom1x3t4aa_ Lt8aadoazxtd6c937.jpg "src=" http://s3.51cto.com/wyfs02/M00/73/35/wKiom1X3t4aA_lT8AADOAZXtd6c937.jpg "width=" 302 " height= "385"/>
This article is from the "alan_y (upspringing)" blog, so be sure to keep this source http://alany.blog.51cto.com/6125308/1694937
Android Development-Fix custom GridView Height first item Height exception problem