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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:11:44+00:00 2026-05-30T17:11:44+00:00

I am having trouble to get display result from JSON. Userfunctions.java To get the

  • 0

I am having trouble to get display result from JSON.

Userfunctions.java

To get the id and then post it into PHP.

private static String imageURL = "http://xxx/imageDisplay.php";
public JSONObject imageDisplay(String id){
    // Building Parameters
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("id", id));
    JSONObject json = jsonParser.getJSONFromUrl(imageURL, params);
    return json;
}

PictureActivity.java

import org.example.veniew.library.UserFunctions; 
public class PictureActivity extends Activity {

private static final String TAG_ID = "ID";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.grid_layout);

    Intent picAct = getIntent();
    //get ID from previos activity
    String id = picAct.getStringExtra(TAG_ID);

    UserFunctions userFunction = new UserFunctions();
    JSONObject json = userFunction.imageDisplay(id);

    try {
        JSONObject jsonResponse = new JSONObject(new String());
        JSONArray imagelink = jsonResponse.getJSONArray("imagelink");

        String link = imagelink.toString();
        Toast.makeText(this, link, Toast.LENGTH_LONG).show();
        //How to TOAST imgPath?

    }catch (JSONException e) {
        e.printStackTrace();
    }
}

JSON from imageDisplay.php if ID is = 1

{"imgDisplay":[{"imgID":"1","imgPath":"imgFolder\/Penguins.jpg","ID":"1"},{"imgID":"2","imgPath":"imgFolder\/Jellyfish.jpg","ID":"1"},{"imgID":"4","imgPath":"imgFolder\/Koala.jpg","ID":"1"}]}

How do i make a TOAST to display the result of just “imgPath”??

Thankyou.

  • 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-05-30T17:11:45+00:00Added an answer on May 30, 2026 at 5:11 pm

    i dont know how the logcat is showing this info

    anyway here is the solution

      JSONObject json = userFunction.imageDisplay(id);
      try { 
    
    
         JSONArray imagelink = json.getJSONArray("imgDisplay");
    
         String firstlink=imagelink.getJSONObject(0).getString("imgPath");
    
         String secondlink=imagelink.getJSONObject(1).getString("imgPath"); 
    
    
        String link = imagelink.toString();
         Toast.makeText(this, firstlink, Toast.LENGTH_LONG).show();
         //How to TOAST imgPath? 
      }catch (JSONException e) {
         e.printStackTrace();     
      }
    

    i considered you have just this data if you have more then you have to use loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting JSON data from my Rails app to display on a
I am having real trouble trying to get decent answers to my questions from
I'm having trouble with this PHP script where I get the error Fatal error
I am having trouble, I am trying to get updates from a messages table
I am having trouble trying to get iterators for inner sub-containers. Basically imagine this
I'm having trouble figuring out how to get the testing framework set up and
I am having trouble working out how to get a simple fade in fade
I'm having a real trouble to get accents right, and I believe this may
I'm having trouble with something that I thought would be easy... I can't get
I'm having trouble setting up my svn. I used apt-get install subversion to install

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.