Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26794] Android: Cannot show / hide a view created via Common JS

GitHub Issuen/a
TypeBug
PriorityHigh
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterHans Knöchel
AssigneeUnknown
Created2019-02-03T11:14:20.000+0000
Updated2019-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();
}

Comments

  1. Joshua Quick 2019-02-04

    Hmm... I can't reproduce the issue. I've tried the below code which dynamically calls a label's show() and hide() methods, as well as setting its "visible" property true/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();
       
  2. Joshua Quick 2019-02-04

    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();
       
  3. Hans Knöchel 2019-02-04

    The main difference is that my example is about a require()'d view.

JSON Source