0
votes

The widget that I have is working on other xml files..except for one... The process goes like this...There's a view that when clicked, a window will open..

<Alloy>
  <View class="vertical hsize">
    <View class="hsize">
      <Require src="actionbar" type="widget" />
    </View>
    <ScrollView class="container vertical whitebg">
      <View class="downloadRowContainer horizontal">
        <View class="downloadRow horizontal">
          <View id="itemDl" onClick="viewItem" class="downloadItem graybg" />
          <View class="divider" />
          <View class="downloadItem graybg" />
        </View>
      </View>
      <View class="downloadRowContainer horizontal">
        <View class="downloadRow horizontal">
          <View class="downloadItem graybg" />
          <View class="divider" />
          <View class="downloadItem graybg" />
        </View>
      </View>
    </ScrollView>
  </View>
</Alloy>

Here's the js:

function viewItem(e){
  var showItem = Alloy.createController('viewdl').getView().open();
}

It works it opens viewdl.xml but the widget ain't working anymore on viewdl.xml alone.Any idea why? Here's viewdl.xml(viewdl.js is blank):

<Alloy><Window class="vertical">
<View class="vertical hsize">
  <View class="hsize"><Require src="actionbar" type="widget"/></View>
    <ScrollView class="container vertical blackbg">
      <View class="imgContainer"></View>
        <View class="division"></View>
          <Label>DOWNLOAD THIS WALLPAPER</Label>
    </ScrollView>
</View></Window></Alloy>
1
Can you show code of viewdl.xml and viewdl.js. Also what error do you get in console.turtle
theres no error..it works but not the widget wait ill post viewdl.xmlRon Manuela
I think you have not pasted complete code of viewdl.xml code. Also can you provide link/info of your actionbar widget. A quick try could be use var showItem = Alloy.createController('viewdl').getView().open({fullscreen:false});turtle
sorry about that..one quick question...how do you open an .xml file without <Window></Window> tags..cause the other .xml files with the widget are working fine..and is alloy.createcontroller only for opening windows...very new to titanium sorryRon Manuela
You cannot open an xml file without window because open method is not available for view. You can export the content of the xml and add it to current window or view like $.myCurrentView.add(Alloy.createController('viewdl').getView());turtle

1 Answers

0
votes

Let me elaborate some points which I think are creating issues:

  • The root of the UI is Window or TabGroup or NavigationWindow/NavigationGroup : So these elements are responsible for opening and closing of the content/container in screen.
  • You can add some other View or its sub-element(Label,TableView,etc) to a window using add method.
  • IMO the widget should be added to the main container.

A simple example, let say we want 2 window application.

  • 1st Window has a button which opens 2nd window.
  • 2nd Window has 2 buttons
    1. 1st button close the current window.
    2. 2nd button loads some other view ( xml file ) to current window.

index.xml

<Alloy>
  <Window id="first" layout="vertical" >
     <Require src="actionbar" type="widget" />
     <Button onClick="openWin2" title="Open" />
  </Window>
</Alloy>

index.js

function openWin2() {
  Alloy.createController('window2').getView().open({fullscreen:false});
}

window2.xml

<Alloy>
  <Window id="second" layout="vertical" >
     <Require src="actionbar" type="widget" />
     <Button onClick="closeWin" title="Close" />
     <Button onClick="loadData" title="Load Data" />
     <View id="dynamicView" height="100px" width="100px"></View>
  </Window>
</Alloy>

window2.js

function closeWin() {
  $.second.close();
}

function loadData() {
  $.dynamicView.add(Alloy.createController('dynamicData').getView());
}

dynamicData.xml

<Alloy>
  <Label >Winter is coming !!</Label>
</Alloy>

Hope it is helpful.