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 8889123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:11:07+00:00 2026-06-14T22:11:07+00:00

Hi all i am trying to display the data that i am getting from

  • 0

Hi all i am trying to display the data that i am getting from a JSON string which contain a name,image and content (textview, imageview and a textview).I am able to get the data from JSON but i am not able to display it and even i am not getting any error in my Logcat.

The code i am trying is

try {
     bookDetails = json.getJSONArray(TAG_DETAILS);
     for (int i = 0; i < bookDetails.length(); i++) 
     {
     JSONObject c = bookDetails.getJSONObject(i);
     String image1 = c.getString(TAG_IMAGE1);
     String image2=c.getString(TAG_IMAGE2);
     String Bid = c.getString(TAG_ID);
     String Bname = c.getString(TAG_NAME);
     String Bdesc= c.getString(TAG_DESCRIPTION);
     String BbookId=c.getString(TAG_BOOKID);
     HashMap<String, String> map = new HashMap<String, String>();
     map.put(TAG_IMAGE1, image1);
     map.put(TAG_IMAGE2, image2);
     map.put(TAG_ID,Bid);
     map.put(TAG_NAME,Bname);
     map.put(TAG_DESCRIPTION,Bdesc);
     map.put(TAG_BOOKID,BbookId);
     booksList.add(map);
     String[] captionArray = (String[]) ((List<NameValuePair>) map).toArray(new String[map.size()]);
     ItemsAdapter itemsAdapter=new ItemsAdapter(DetailsActivity.this, R.layout.details,booksList);
     setListAdapter(itemsAdapter);
     }
       } catch (JSONException e)
         {
             e.printStackTrace();
          }
            return null;
   }

and My adapter is

 private class ItemsAdapter extends BaseAdapter implements ListAdapter
        {
            String[] items;


            public ItemsAdapter(DetailsActivity detailsActivity,
                    int details, ArrayList<HashMap<String, String>> booksList) {
                // TODO Auto-generated constructor stub
                this.items = items;
            }
            public View getView( int POSITION, View convertView,ViewGroup parent)
            {
                TextView cap = null ;
                View view = convertView;
                ImageView img = null;
                if (view == null) 
                {
                    LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    view = vi.inflate(R.layout.details, null);
                }
                img = (ImageView) view.findViewById(R.id.smallImage);
                Log.i("sss","sss");
                cap = (TextView) view.findViewById(R.id.caption);
                cap.setText(mapName.get(POSITION));
                img.setImageBitmap(BitmapFactory.decodeByteArray(map.get(POSITION), 0, map.get(POSITION).length));
                return view;
            }
            public int getCount() 
            {
                return items.length;
            }
            public Object getItem(int position) 
            {
                return position;
            }
            public long getItemId(int position) 
            {
                return position;
            }
        }

My JSON String is

{
    "bookdetails": [
        {
            "bid": "2",
            "name": "Android 2 Application Dev",
            "bookid": "1",
            "description": "Providing in-depth coverage of how to build mobile applications using the next major release of the Android SDK, this invaluable resource takes a hands-on approach to discussing Android with a series of projects, each of which introduces a new feature and highlights techniques and best practices to get the most out of Android.",
            "image1": "http://media.shelf-awareness.com/shelfcontest.png",
            "image2": "http://cache0.bdcdn.net/assets/images/book/medium/9780/4704/9780470452622.jpg"
        }
    ]
}
  • 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-14T22:11:09+00:00Added an answer on June 14, 2026 at 10:11 pm

    you are missing up with JsonObject and JsonArray, just use this

    JSONObject mJsonObject=null;
    JSONArray bookDetails = null;
    try {
        mJsonObject= new JSONObject("YourJson");
        bookDetails = mJsonObject.getJSONArray("bookdetails");
    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    
    try {
        System.out.println("bookDetails.length() : "+bookDetails.length());
        for (int i = 0; i < bookDetails.length(); i++) 
        {
            JSONObject c = bookDetails.getJSONObject(i);
    
            String image1 = c.getString("image1");
            String image2=c.getString("image2");
            String Bid = c.getString("bid");
            String Bname = c.getString("name");
            String Bdesc= c.getString("description");
            String BbookId=c.getString("bookid");
            }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display JSON data that I retrieve from an ajax call
Hey all i am trying to find examples of getting data back from a
I'm trying to display some checkbox in a form after getting the data from
From any specific Post, I am trying to display all images, with their corresponding
I'm trying to loop through a list of results from MySQL and display all
I am trying to retrieve data from mysql then display it on android listview.
I have an element in my header that is getting data from a js
I am trying to build my first iOS app that parses json from a
I'm trying to display all the 'legs' for each of my 'trips' in my
I am trying to display all possible values for a sub-property. Below I am

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.