Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
To display Listview using JSON in Android !
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Meena Rengarajan  
View profile  
 More options Aug 4 2012, 1:06 am
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Fri, 3 Aug 2012 22:06:18 -0700 (PDT)
Local: Sat, Aug 4 2012 1:06 am
Subject: To display Listview using JSON in Android !

This is my code. Listview using Json in Android . But my lists is not
displaying when i click a button.. Only displaying first activity alone.
Whats wrong here ? can anyone help me ..
try {
      JSONObject json1=new JSONObject(resultJSON);
      JSONArray jsonArray=json1.getJSONArray("");
      int length = jsonArray.length();
      System.out.println("json1:"+json1);
      System.out.println("jsonarray:"+jsonArray);
      String[] str1 = new String[length];
      for (int i = 0; i < str1.length; i++) {
str1[i]=jsonArray.getJSONObject(i).getJSONObject("FORM").getJSONArray("FPRO P".getJSONObject(0).getString("FNAME");

}
} catch (Exception e) {

// TODO: handle exception
Toast.makeText(NewActivity.this,"sorry", Toast.LENGTH_LONG).show();
}

 ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
android.R.id.text1,str1);

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
HideCheck  
View profile  
 More options Aug 4 2012, 1:16 am
From: HideCheck <hidech...@gmail.com>
Date: Sat, 4 Aug 2012 14:16:17 +0900
Local: Sat, Aug 4 2012 1:16 am
Subject: Re: [android-developers] To display Listview using JSON in Android !
I guess as follows.

1. Argment is empty.
JSONArray jsonArray=json1.getJSONArray("");

2. Did you write this?
ListView#setAdapter(adapter)

Best Regards

2012/8/4 Meena Rengarajan <meenasoft...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Meena Rengarajan  
View profile  
 More options Aug 4 2012, 1:36 am
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Sat, 4 Aug 2012 11:06:36 +0530
Local: Sat, Aug 4 2012 1:36 am
Subject: Re: [android-developers] To display Listview using JSON in Android !

You mean this one ?  Yeah, i wrote like this ,

 ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
android.R.id.text1,str1);

ListView lv.setAdapter(adapter);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Meena Rengarajan  
View profile  
 More options Aug 4 2012, 1:52 am
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Fri, 3 Aug 2012 22:52:07 -0700 (PDT)
Local: Sat, Aug 4 2012 1:52 am
Subject: Re: To display Listview using JSON in Android !

I do not understand what mistake here ? please anyone can help me ? This is
my code..

 String result=getIntent().getStringExtra("Entry");
        result = result.substring(result.indexOf('#')+1);
        //String JsonData;
        String resultJSON=getIntent().getStringExtra("JsonData");
      try {
      JSONObject jsonObj=new JSONObject(resultJSON);
      //str1=json1.getString("UploadResult");
          JSONArray jsonArray=jsonObj.getJSONArray("");
      int length = jsonArray.length();
      System.out.println("jsonObj:"+jsonObj);
      System.out.println("jsonarray:"+jsonArray);
     String[] str1 = new String[length];
      for (int i = 0; i < str1.length; i++) {
str1[i]=jsonArray.getJSONObject(i).getJSONObject("FORM").getJSONArray("FPRO P").getJSONObject(0).getString("FNAME");

}
} catch (Exception e) {

// TODO: handle exception
//Toast.makeText(NewActivity.this,"sorry", Toast.LENGTH_LONG).show();
}

 ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
android.R.id.text1,str1);

lv.setAdapter(adapter);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Meena Rengarajan  
View profile  
 More options Aug 4 2012, 1:58 am
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Sat, 4 Aug 2012 11:28:45 +0530
Local: Sat, Aug 4 2012 1:58 am
Subject: Re: [android-developers] Re: To display Listview using JSON in Android !

My debugging point is not going from this line
JSONArray jsonArray=jsonObj.getJSONArray(""); but exception is caught in
Catch in this code..

JSONArray jsonArray=jsonObj.getJSONArray("");
      int length = jsonArray.length();
      System.out.println("jsonObj:"+jsonObj);
      System.out.println("jsonarray:"+jsonArray);
     String[] str1 = new String[length];
      for (int i = 0; i < str1.length; i++) {
str1[i]=jsonArray.getJSONObject(i).getJSONObject("FORM").getJSONArray("FPRO P").getJSONObject(0).getString("FNAME");

}

On Sat, Aug 4, 2012 at 11:22 AM, Meena Rengarajan <meenasoft...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
HideCheck  
View profile  
 More options Aug 4 2012, 3:13 am
From: HideCheck <hidech...@gmail.com>
Date: Sat, 4 Aug 2012 16:13:49 +0900
Local: Sat, Aug 4 2012 3:13 am
Subject: Re: [android-developers] Re: To display Listview using JSON in Android !
example json
{"node":["value1","value2]}

code:
JSONObject root = json.getJSONObject(resultJson);
JSONArray node = root.getJSONArray(“node”);    //<- You getJSONArray(“”);

Best Regards

2012/8/4 Meena Rengarajan <meenasoft...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Meena Rengarajan  
View profile  
 More options Aug 4 2012, 3:17 am
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Sat, 4 Aug 2012 00:17:00 -0700 (PDT)
Subject: Re: To display Listview using JSON in Android !

How do i wanna split a string into two parts here by omitting first
character ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
HideCheck  
View profile  
 More options Aug 4 2012, 3:14 am
From: HideCheck <hidech...@gmail.com>
Date: Sat, 4 Aug 2012 16:14:54 +0900
Local: Sat, Aug 4 2012 3:14 am
Subject: Re: [android-developers] Re: To display Listview using JSON in Android !
sorry misstake

code:
JSONObject root = new JSONObject(resultJson);
JSONArray node = root.getJSONArray(“node”);    //<- You getJSONArray(“”);

2012/8/4 HideCheck <hidech...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Meena Rengarajan  
View profile  
 More options Aug 4 2012, 3:33 am
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Sat, 4 Aug 2012 13:03:02 +0530
Local: Sat, Aug 4 2012 3:33 am
Subject: Re: [android-developers] Re: To display Listview using JSON in Android !

How should i use Array adapter here to get listview values .. I am very new
to Android can anyone help me please..

I used this in my code,

ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
android.R.id.text1,str1);
lv.setAdapter(adapter);

On Sat, Aug 4, 2012 at 12:47 PM, Meena Rengarajan <meenasoft...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
HideCheck  
View profile  
 More options Aug 4 2012, 3:51 am
From: HideCheck <hidech...@gmail.com>
Date: Sat, 4 Aug 2012 16:51:31 +0900
Local: Sat, Aug 4 2012 3:51 am
Subject: Re: [android-developers] Re: To display Listview using JSON in Android !
I guess
Show of ListView rather than wrong, You have failed to parse JSON.

> ArrayAdapter<String> adapter = new
> ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
> android.R.id.text1,str1);
> lv.setAdapter(adapter);

this code is correct.

Structure of the JSON is?

2012/8/4 Meena Rengarajan <meenasoft...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Meena Rengarajan  
View profile  
 More options Aug 4 2012, 3:25 pm
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Sun, 5 Aug 2012 00:55:01 +0530
Local: Sat, Aug 4 2012 3:25 pm
Subject: Re: [android-developers] Re: To display Listview using JSON in Android !

Yeah , exactly what you have said is right . Now works on well ! I havent
parsed JSON. I am new to this topic. Anywys thankyou  :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Meena Rengarajan  
View profile  
 More options Aug 5 2012, 9:58 am
From: Meena Rengarajan <meenasoft...@gmail.com>
Date: Sun, 5 Aug 2012 19:28:20 +0530
Local: Sun, Aug 5 2012 9:58 am
Subject: Re: [android-developers] Re: To display Listview using JSON in Android !

But i need to knw one thing, if i use Array adapter before assigning the
values of str[i] its displaying listview also if i set adapter after
assigning values to Str[i] also dispalying listview . Why so ?

For an example this line :-

str1[i]=jsonArray.getJSONObject(i).getJSONObject("FORM").
getJSONArray("FPROP")
.getJSONObject(0).getString("FNAME");
                }
         ArrayAdapter<String>adapter=new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1,android.R.id.text1,str1);
         lv.setAdapter(adapter);
        }

And my code is here ,

 JSONArray jsonArray=jsonObj.getJSONArray("formlist");
          int length = jsonArray.length();
         String[] str1 =new String[length];
        // ArrayAdapter<String>adapter=new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1,android.R.id.text1,str1);
        // lv.setAdapter(adapter);

        // ArrayList<String> items = new ArrayList<String>();
         for (int i = 0; i < length; i++) {

str1[i]=jsonArray.getJSONObject(i).getJSONObject("FORM").
getJSONArray("FPROP")
.getJSONObject(0).getString("FNAME");
                }
         ArrayAdapter<String>adapter=new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1,android.R.id.text1,str1);
         lv.setAdapter(adapter);
        }

     catch (JSONException e) {

On Sun, Aug 5, 2012 at 12:55 AM, Meena Rengarajan <meenasoft...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »