Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:32:47+00:00 2026-06-02T18:32:47+00:00

I am trying to create a single column picker whose data is derived from

  • 0

I am trying to create a single column picker whose data is derived from a json doc. Right now i am coding for an iOS device, but plan to use same code for android. When i run this code, the picker is empty. Any help is appreciated!

////
var win = Titanium.UI.createWindow({
    title:"Creating a Single-Column Picker",
    backgroundColor:"#FFF",
    exitOnClose:true
});

var url ="http://stats.catchitkansas.com/sunflower/cik/xml/app/app_master_schools.json"; //  rss     feed url

var json, object_name, locatie, i, row, title, val;

//A single column picker

var picker = Ti.UI.createPicker({
bottom:0,
});

var xhr = Ti.Network.createHTTPClient({ 

    onload: function(e) { // Ti.API.debug(this.responseText);

        json = JSON.parse(this.responseText); 
            for (i = 0; i < json.object_name.length; i++) { 

            locatie = json.object_name[i]; 

            picker.add(Ti.UI.createPickerRow({title: e.locatie.title}));
            }   
        //Now, we need add the pickerRow objects in the data array to the picker
        Ti.API.debug(this.responseText);
        alert('success');

        }, 
    }

);
picker.selectionIndicator = true;

xhr.open('GET',url);

xhr.send();

//This label contains text that will change with each picker change
var results = Titanium.UI.createLabel({
    text:"Select from the picker below",
    height:40,
    width:"auto",
    top:20  
});

//When using a picker, listen for the "change" event
picker.addEventListener("change", function(e){
    results.text = e.row.title + ": " + e.row.val; //Pull the title and val properties from the     selected pickerRow object (accessed via e.row)
});

win.add(picker);
win.add(results);

win.open();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:32:49+00:00Added an answer on June 2, 2026 at 6:32 pm

    Issue #1

    Your data feed is returning improperly formatted JSON.

    Change this

    "object_name": {

    to

    "object_name":

    (Found by running the JSON through http://jsonlint.com/)


    Issue #2

    Change this

    picker.add(Ti.UI.createPickerRow({title: e.locatie.title}));

    to

    picker.add(Ti.UI.createPickerRow({title: locatie.title}));

    The locatie object isn’t part of the event variable e, it’s a stand-alone variable.


    Issue #3

    The picker is being added before the HttpClient request is finished.

    You should move win.add(picker); to just after the for loop inside the onload callback.

    var xhr = Ti.Network.createHTTPClient({ 
        onload: function(e) { 
            json = JSON.parse(this.responseText); 
    
            for (i = 0; i < json.object_name.length; i++) { 
                locatie = json.object_name[i];
    
                picker.add(Ti.UI.createPickerRow({title: locatie.title}));
            }   
    
            win.add(picker);
            alert('success');
        } 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a single instance Qt application and I'm at the point
I'm trying to create a use-once HTTP server to handle a single callback and
I am trying to get the data from a Oracle View created on XML
I'm trying to create a cube with a single measure. This measure is a
I'm trying to create a single table for private messaging on a website. I
I am trying to create an ANI lookup table from 2 separate tables, one
Is there any way to get all the data from a column family or
I am trying create a WCF service that leverages the WPF MediaPlayer on the
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying create a delegate representation of constructor by emitting a Dynamic Method,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.