Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: How to display JSON Post result
    text
    copied!<p>I am having trouble to get display result from JSON.</p> <p>Userfunctions.java <br>To get the id and then post it into PHP.</p> <pre><code>private static String imageURL = "http://xxx/imageDisplay.php"; public JSONObject imageDisplay(String id){ // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("id", id)); JSONObject json = jsonParser.getJSONFromUrl(imageURL, params); return json; } </code></pre> <p>PictureActivity.java<br></p> <pre><code>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(); } } </code></pre> <p>JSON from imageDisplay.php if ID is = 1</p> <pre><code>{"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"}]} </code></pre> <p>How do i make a TOAST to display the result of just "imgPath"??</p> <p>Thankyou.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload