Results 1 to 4 of 4
  1. #1
    viviosoft is offline Member
    Join Date
    Sep 2011
    Posts
    7
    Rep Power
    0

    Default Compile Array information

    Hello all -

    I'm VERY new to java and I'm sure someone here will be able to provide me with a solution. My problem is this... I need to compile or build an array from the following information. So I can output the information to a list. This project is for an android application and the method setListAdapter() accepts the arrayed information.

    Java Code:
    	    	JSONArray jArray = new JSONArray(returnedValues);
    	        
    	        for(int i=0; i < jArray.length(); i++){
    	                //Get an output to the screen
    	            JSONObject json_data = jArray.getJSONObject(i);
    	            [B]invArray[/B][] inv = json_data.getString("itemDesc");            
    	        }
    
    		setListAdapter(new ArrayAdapter<String>(this, R.layout.status, [B]invArray[/B]));
    Here's the code in its entirety...

    Java Code:
    	    HttpHelper httpHelper = new HttpHelper();
    	    String returnedValues = httpHelper.getServerData(URL, KEY, VALUE);
    	    
    	    try{
    	        
    	    	JSONArray jArray = new JSONArray(returnedValues);
    	        
    	        for(int i=0; i < jArray.length(); i++){
    	                //Get an output to the screen
    	            JSONObject json_data = jArray.getJSONObject(i);
    	            invArray[] inv = json_data.getString("itemDesc");            
    	        }
    	
    	    }
    	    catch(JSONException e){
    			    Log.e("log_tag_activity", "Error parsing data "+e.toString());
    		}
    	  
    
    	    LinearLayout rootLayout = new LinearLayout(getApplicationContext());  
    
    		setListAdapter(new ArrayAdapter<String>(this, R.layout.status, invArray));
    
    	    ListView lv = getListView();
    	    lv.setTextFilterEnabled(true);
    Thanks for any help you can provide me.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: Compile Array information

    Moved from 'New to Java'

    db

  3. #3
    viviosoft is offline Member
    Join Date
    Sep 2011
    Posts
    7
    Rep Power
    0

    Default Re: Compile Array information

    Please now reference this thread... listView and listArray methods

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Compile Array information

    Java Code:
    invArray[] inv = json_data.getString("itemDesc");
    The syntax of this statement says that the getString() method returns a array of invArray object(s).
    Is that correct? If not please describe what it does return.

    Then there is confusion in this statement. invArray is used here as a variable vs.:
    Java Code:
    setListAdapter(new ArrayAdapter<String>(this, R.layout.status, invArray));

Similar Threads

  1. need to read information from file into array
    By sadeem in forum New To Java
    Replies: 8
    Last Post: 05-15-2011, 10:00 PM
  2. Replies: 5
    Last Post: 04-27-2011, 09:14 PM
  3. Need information...
    By nikkka in forum New To Java
    Replies: 1
    Last Post: 03-07-2011, 02:25 PM
  4. Replies: 9
    Last Post: 11-13-2010, 11:04 PM
  5. Replies: 3
    Last Post: 04-07-2008, 06:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •