Sample RSS within Application

You must Login before you can answer or comment on any questions.

I am currently designing an application for iOS and Android where on one tab there are a few rows and for one of the rows it goes to a RSS feed for news. I have used the sample RSS feed code within the application and it works great except the back button in the upper left hand corner as well as the tabs disappear on the bottom (when looking at it in iOS).

Does anyone know what code to put in or tweak so that both the back button and tabs on the bottom stay?

— asked 1 year ago by J W
0 Comments

3 Answers

You are probably opening a modal or standalone window instead of adding it to the current tab's stack and opening it through Tab.open().

If you can show me the part of the code where you're creating and opening the RSS feed window, I can show you how to modify it to open it inside the tab.

Or, check out the documentation for Titanium.UI.Tab.open method.

— answered 1 year ago by Goran Skledar
answer permalink
4 Comments
  • This is the code I am using to open up the rss feed from a row - I'm thinking it is here or in the ApplicationWindow.js that comes with the RSS feed example:

    var win = Titanium.UI.currentWindow;
     
    var tableView;
    var data = [];
     
    {
        var row = Ti.UI.createTableViewRow();
        row.selectedBackgroundColor = '#fff';
        row.height = 150;
        row.hasChild = true;
        row.test = 'latestnews.js';
     
        var photo = Ti.UI.createView({
            backgroundImage:'../images/news.jpg',
            top:43,
            left:10,
            width:70,
            height:110,
        });
        row.add(photo);
     
     
        var user = Ti.UI.createLabel({
            color:'#000000',
            font:{fontSize:22,fontWeight:'bold', fontFamily:'Arial'},
            left:95,
            top:23,
            height:30,
            width:200,
            text:'Latest News'
        });
     
        row.add(user);
     
        var comment = Ti.UI.createLabel({
            color:'#222',
            font:{fontSize:16,fontWeight:'normal', fontFamily:'Arial'},
            left:95,
            top:53,
            height:80,
            width:200,
            text:'For all the latest news and ongoings.'
        });
        row.add(comment);
     
        data.push(row);
    }
     
     
    {
        var row = Ti.UI.createTableViewRow();
        row.selectedBackgroundColor = '#fff';
        row.height = 150;
        row.hasChild = true;
        row.test = 'twitter.js';
     
        var photo = Ti.UI.createView({
            backgroundImage:'../images/twiiter.jpg',
            top:20,
            left:10,
            width:70,
            height:150,
        });
        row.add(photo);
     
     
        var user = Ti.UI.createLabel({
            color:'#000000',
            font:{fontSize:22,fontWeight:'bold', fontFamily:'Arial'},
            left:95,
            top:32,
            height:50,
            width:200,
            text:'Follow Us \non Twitter!'
        });
     
        row.add(user);
     
        var comment = Ti.UI.createLabel({
            color:'#222',
            font:{fontSize:16,fontWeight:'normal', fontFamily:'Arial'},
            left:95,
            top:64,
            height:80,
            width:200,
            text:'Be sure to see the latest tweets!'
        });
        row.add(comment);
     
        data.push(row);
    }
     
    tableView = Titanium.UI.createTableView({
        data:data,
        scrollable:true,
        backgroundColor:'white' 
    });
     
    tableView.addEventListener('click', function(e)
    {
        if (e.rowData.test)
        {
            var win = Titanium.UI.createWindow({
                url:e.rowData.test,
                title:e.rowData.title
            });
            Titanium.UI.currentTab.open(win,{animated:true});
        }
    });
     
    win.add(tableView);

    — commented 1 year ago by J W

  • Looking at the code, you're already opening the window correctly through the currentTab - which window is giving you issues in this code, the one defined in latestnews.js?

    In that case, could you also post the part of the code in that file where you define your window's properties (if any)?

    — commented 1 year ago by Goran Skledar

  • Here is the code for the latestnews.js

    if (Ti.version < 1.8 ) {
        alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');
    }
    else {
        // This is a single context application with multiple windows in a stack
        (function() {
            //determine platform and form factor and render appropriate components
            var osname = Ti.Platform.osname,
                height = Ti.Platform.displayCaps.platformHeight,
                width = Ti.Platform.displayCaps.platformWidth;
     
            //considering tablet to have one dimension over 900px - can define your own
            var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899));
     
            var Window;
            if (isTablet) {
                Window = require('ui/tablet/ApplicationWindow');
            }
            else {
                if (osname === 'android') {
                    Window = require('ui/handheld/android/ApplicationWindow');
                }
                else if (osname === 'mobileweb') {
                    Window = require('ui/handheld/mobileweb/ApplicationWindow');
                }
                else {
                    Window = require('ui/handheld/ios/ApplicationWindow');
                }
            }
            new Window().open();
        })();
    }
    and here is the code for the ApplicationWIndow for iOS:
    //Application Window Component Constructor
    function ApplicationWindow() {
        //declare module dependencies
        var rss = require('services/rss'),
            MasterView = require('ui/common/MasterView'),
            DetailView = require('ui/common/DetailView');
     
        //create object instance
        var self = Ti.UI.createWindow({
            backgroundColor:'#ffffff'
        });
     
        //construct UI
        var masterView = new MasterView(),
            detailView = new DetailView();
     
        //create master view container
        var masterContainerWindow = Ti.UI.createWindow({
            title:'Latest News'
        });
        var button = Ti.UI.createButton({
            systemButton: Ti.UI.iPhone.SystemButton.REFRESH
        });
        button.addEventListener('click', function(e) {
            refreshRSS();
        });
        masterContainerWindow.rightNavButton = button;
        masterContainerWindow.add(masterView);
     
        //create detail view container
        var detailContainerWindow = Ti.UI.createWindow();
        detailContainerWindow.add(detailView);
     
        //create iOS specific NavGroup UI
        var navGroup = Ti.UI.iPhone.createNavigationGroup({
            window:masterContainerWindow
        });
        self.add(navGroup);
     
        //add behavior for master view
        masterView.addEventListener('itemSelected', function(e) {
            detailView.showArticle(e.link);
            navGroup.open(detailContainerWindow);
        });
     
        function refreshRSS() {
            rss.loadRssFeed({
                success: function(data) {
                    masterView.refreshRssTable(data);
                }
            });
        }
     
        // load initial rss feed
        refreshRSS();
     
        return self;
    };
    module.exports = ApplicationWindow;

    — commented 1 year ago by J W

  • Show 1 more comment

If you open it through win.open() it will overlap the views. To add it to the window stack you gotta tabGroup.activeTab.open(win); this will push it to the top of the stack and open it, this also generates an auto-back button for you.

Its because this new Window().open();, this will open the window in standalone mode and fill the screen (overlaps your TabGroup);

So you basically add two windows..

this keeps your tabGroup

var win = Titanium.UI.createWindow({
            url:e.rowData.test,
            title:e.rowData.title
        });
        Titanium.UI.currentTab.open(win,{animated:true});
this overlaps it all new Window().open();

— answered 1 year ago by Alexander Bauer
answer permalink
1 Comment
  • Sorry, not sure if I understand or if I have just been staring at this for so long but what and where do I exactly put that code so that I can open a window within a window.

    — commented 1 year ago by J W

Your Answer

Think you can help? Login to answer this question!