android - How to sort LinearLayout's children programatically -


i have linear layout horizontal orientation has few imageviews in (hardcoded in xml). have sort them based on multiselectlistpreference (all checked first , unchecked later). put checked ones in beginning tried

((linearlayout)imageview.getparent()).removeview(imageview); ((linearlayout)imageview.getparent()).addview(imageview,0); 

and did nothing unchecked. gives me "the specified child exists. must call removeview(view) on view's given parent" though i've called it. may because imageviews present in xml. how can obtain desired arrangement of child imageviews. if @ linearlayout not suffice, should use recyclerview here , heavier?

cast parent view viewgroup removeview method work.

((viewgroup)imageview.getparent()).removeview(imageview); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -