[TIMOB-26794] Android: Cannot show / hide a view created via Common JS
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Android |
| Labels | n/a |
| Reporter | Hans Knöchel |
| Assignee | Unknown |
| Created | 2019-02-03T11:14:20.000+0000 |
| Updated | 2019-02-04T19:18:17.000+0000 |
Description
This is a weird one. When creating a view programmatically, e.g. via a CommonJS file, it later cannot be shown / hidden anymore. We need to elaborate more on it, but it's similar to the following (using Alloy):
**xp.ui.js**
exports.createMyView = (args = {}) => {
};
**index.xml**
<Alloy>
<Window onOpen="hideView">
<MyView id="theView" width="100" height="100" backgroundColor="red" />
</Window>
</Alloy>
**index.js**
function hideView() {
$.theView.hide();
}
Hmm... I can't reproduce the issue. I've tried the below code which dynamically calls a label's
show()andhide()methods, as well as setting its "visible" propertytrue/false.var window = Ti.UI.createWindow({ layout: "vertical", }); var label = Ti.UI.createLabel({ text: "Hello World!", top: "40dp", // visible: false, }); //label.hide(); window.add(label); var showButton = Ti.UI.createButton({ title: "show()", top: "40dp", }); showButton.addEventListener("click", function() { label.show(); }); window.add(showButton); var hideButton = Ti.UI.createButton({ title: "hide()", top: "20dp", }); hideButton.addEventListener("click", function() { label.hide(); }); window.add(hideButton); var visibleTrueButton = Ti.UI.createButton({ title: "visible = true", top: "40dp", }); visibleTrueButton.addEventListener("click", function() { label.visible = true; }); window.add(visibleTrueButton); var visibleFalseButton = Ti.UI.createButton({ title: "visible = false", top: "20dp", }); visibleFalseButton.addEventListener("click", function() { label.visible = false; }); window.add(visibleFalseButton); window.open();The below code should be a similar equivalent of your Alloy example. But I cannot reproduce the issue with this either.
var window = Ti.UI.createWindow(); var view = Ti.UI.createView({ backgroundColor: "red", width: "100dp", height: "100dp", }); window.add(view); window.addEventListener("open", function() { view.hide(); setTimeout(function() { view.show(); }, 2000); }); window.open();The main difference is that my example is about a require()'d view.