The project needs to display more than one picture in the ListView, using the GridView, but if the use of ordinary gridview,item just show a part, beyond the first line will not be able to show, this is very silent, So we have to inherit the GridView rewrite the Onmeasure method to measure the height of the child control ...
This is just a code for defining the GridView, which is used directly in XML, and can be invoked in the ListView adapter:
| The code is as follows |
Copy Code |
public class Gridviewforlistview extends GridView { public Gridviewforlistview (context context) { & nbsp; Super (context); } public Gridviewforlistview, AttributeSet Attrs) { super (context, attrs); } @Override protected void onmeasure (int widthmeasurespec, int heightmeasurespec) { int expandspec = Measurespec.makemeasurespec (Integer.max_value >> 2, measurespec.at_most); super.onmeasure (Widthmeasurespec, Expandspec); } } |