listview - Android: Can I set converted view layout in getView() -
i'm setting different height custom listview items based on screen orientation, , in code below listen screen orientation changes, , set global value according it, , when getview(...) gets called on listview items set height of converted view.
my question is, there better solution this?
how bad approach affect ui loading speed process?
i'm targeting api14+
p.s: (200 & 300) below added here example, not fixed @ runtime, changed during runtime according screen dpi.
int mconvertviewheight; @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); if (newconfig.orientation == configuration.orientation_landscape) { mconvertviewheight = (int) typedvalue.applydimension(typedvalue.complex_unit_dip, 200, getresources().getdisplaymetrics()); } else if (newconfig.orientation == configuration.orientation_portrait) { mconvertviewheight = (int) typedvalue.applydimension(typedvalue.complex_unit_dip, 300, getresources().getdisplaymetrics()); } }
in listview custom array adapter
@override public view getview(final int aconvertviewposition, view aconvertview, viewgroup parent) { mparams = aconvertview.getlayoutparams(); mparams.height = mmainactivity.mconvertviewheight; }
if need different item view in portrait/landscape mode, can create different layouts in layout-land , layout-port folders
Comments
Post a Comment