raymondkam / Ti.SwipeRefreshLayout

Titanium module for Android's SwipeRefreshLayout.
Other
37 stars 50 forks source link

Set the view via .add() #3

Open FokkeZB opened 10 years ago

FokkeZB commented 10 years ago

I'd like to be able to set the view via a .add() method:

var myListView = Ti.UI.createListView({
    height: Ti.UI.FILL,
    width: Ti.UI.FILL
});

var swipeRefreshModule = require('com.rkam.swiperefreshlayout');
var swipeRefresh = swipeRefreshModule.createSwipeRefresh({
    height: Ti.UI.FILL,
    width: Ti.UI.FILL
});

swipeRefresh.add(myListview);

$.content.add(swipeRefresh);

This will allow me to use the module in Alloy XML:

<Alloy>
  <Window>
    <SwipeRefresh module="com.rkam.swiperefreshlayout">
      <ListView>
        <!-- listview tags -->
      </ListView>
    </SwipeRefresh>
  </Window>
</Alloy>
sakae-nakajima commented 10 years ago

+1 for this

If this was available, I was not caught with this one: https://github.com/raymondkam/Ti.SwipeRefreshLayout/issues/5

saggy commented 10 years ago

Is there is another solution to add the listview in a module in xml as above fokke mentioned..? beacuse i need to add the listview in xml.

FokkeZB commented 10 years ago

You can always do it via a widget:

index.js

<Widget src="myWidget">
  <ListView />
</Widget>

widget.js

var swipeRefreshModule = require('com.rkam.swiperefreshlayout');
var swipeRefresh = swipeRefreshModule.createSwipeRefresh({
  view: arguments[0].children[0]
});
$.setTopLevelView(swipeRefresh);

(coded it here, haven't checked)

iskugor commented 10 years ago

You can check out 0.3 version in my repo: https://github.com/iskugor/Ti.SwipeRefreshLayout