android - apply padding to only the first view in an adapter -
android - apply padding to only the first view in an adapter -
i trying add together padding single view in array adapter.
in getview() method say:
if(position==0){ rowview.setpadding(60,0,0,0); }
but position isn't right because convertview recycled.
has tried this?
position 0
first item. however, will need set padding normal other items:
if (position == 0) { rowview.setpadding(60, 0, 0, 0); } else { rowview.setpadding(pad, pad, pad, pad); }
alternately, utilize multiple view types homecoming different layout first item:
@override public int getviewtypecount() { homecoming 2; } @override public int getitemviewtype(int position) { homecoming (position == 0) ? 0 : 1; } @override public view getview(view convertview, viewgroup parent, int position) { if (convertview == null) { if (getitemviewtype(position) == 0) { // inflate padded layout } else { // inflate standard layout } } }
android android-adapter
Comments
Post a Comment