You don't really hide drawables, you just don't draw them. Given this bit of information, there are ways to do exactly what you want. One way is to explicitly draw each drawable in the layout, and then to skip the ones that you want to skip...
class MyView extends Ui.View
{
hidden var mHidden = [];
function onUpdate(dc) {
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
dc.clear();
for (var i = 0; i < mLayout.size(); ++i)
{
// Don't draw things that are hidden
if (!mHidden.indexOf(mLayout[i])) {
mLayout[i].draw(dc);
}
}
}
function hideDrawable(drawable) {
mHidden.add(drawable);
}
function showDrawable(drawable) {
mHidden.remove(drawable);
}
};
Another way would be to insert a dummy drawable into the layout in place of the drawable you want to remove...
class Hideable extends Ui.Drawable { hidden var mHidden; function initialize(drawable) { Drawable.initialize({}); mHidden = false; } function hide() { mHidden = true; } function show() { mHidden = false; } function draw(dc) { if (!mHidden) { mDrawable.draw(dc); } } }; class MyView extends Ui.View { function mHideable; function onLayout(dc) { setLayout(...); for (var i = 0; i < mLayout.size(); ++i) { // wrap drawable with the identifier "name" in a // hideable if ("name".equals(mLayout.identifier)) { mHideable = new Hideable(mLayout[i]); mLayout[i] = mHideable; break; } } } function hideDrawable() { mHideable.hide(); } function showDrawable() { mHideable.show(); } };