Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Power Lifting Lever Belt
SkullVamp
Updated:
Saturday at 10:32 PM
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Saturday at 3:55 PM
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Thursday at 2:23 PM
Ad icon
Wechat qr verification
Pawan2005
Updated:
Thursday at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Jun 10, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Json parsing help!!
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="san**" data-source="post: 16891473" data-attributes="member: 392854"><p><span style="color: DarkGreen"><span style="font-size: 15px">Android</span></span></p><p></p><p>{</p><p>// some code </p><p>private String URL_PRODUCTS = "http://your_url";</p><p> JSONParser jsonParser = new JSONParser(); //creating obj frm above class</p><p></p><p></p><p> ArrayList<String> product_categoies = new ArrayList<String>();</p><p> </p><p> ArrayList<String> category_info = new ArrayList<String>();</p><p> </p><p> ListView listView;</p><p> ProgressDialog pDialog; //spinner</p><p></p><p> new GetCategories().execute();</p><p></p><p>}</p><p></p><p>// call to this from your java class. </p><p></p><p> private class GetCategories extends AsyncTask<Void, Void, Void> {</p><p> </p><p> @Override</p><p> protected void onPreExecute() {</p><p> super.onPreExecute();</p><p> pDialog = new ProgressDialog(getActivity());</p><p> pDialog.setMessage("loading categories..");</p><p> pDialog.setCancelable(false);</p><p> pDialog.show();</p><p> </p><p> }</p><p> </p><p> @Override</p><p> protected Void doInBackground(Void... arg0) {</p><p> ServiceHandler jsonParser = new ServiceHandler();</p><p> String json2 = jsonParser.makeServiceCall(URL_PRODUCTS, ServiceHandler.GET);</p><p> </p><p> </p><p> </p><p> </p><p> if (json2 != null) {</p><p> try {</p><p> JSONObject jsonObj = new JSONObject(json2);</p><p> if (jsonObj != null) {</p><p> JSONArray categories = jsonObj</p><p> .getJSONArray("products"); </p><p> </p><p> for (int i = 0; i < categories.length(); i++) {</p><p> JSONObject catObj = (JSONObject) categories.get(i);</p><p> product_categoies.add(catObj.getString("type"));</p><p> category_info.add("tap to open");</p><p> }</p><p> }</p><p> </p><p> } catch (JSONException e) {</p><p> System.out.println("Exception--- -- -- "+e.toString());</p><p> }</p><p> </p><p> } else {</p><p> Log.e("JSON Data", "Didn't receive any data from server!");</p><p> }</p><p> return null;</p><p> }</p><p> </p><p> @Override</p><p> protected void onPostExecute(Void result) {</p><p> super.onPostExecute(result);</p><p> if (pDialog.isShowing())</p><p> pDialog.dismiss();</p><p> setpropertise(); //post executing a method</p><p> </p><p> }</p><p> </p><p> }</p><p></p><p>Manifest eke internet permission denna amathaka karannath epa</p><p> <uses-permission android:name="android.permission.INTERNET"></uses-permission></p><p>// sorry machan..full code eka nam danna hatiyak na..</p></blockquote><p></p>
[QUOTE="san**, post: 16891473, member: 392854"] [COLOR="DarkGreen"][SIZE="4"]Android[/SIZE][/COLOR] { // some code private String URL_PRODUCTS = "http://your_url"; JSONParser jsonParser = new JSONParser(); //creating obj frm above class ArrayList<String> product_categoies = new ArrayList<String>(); ArrayList<String> category_info = new ArrayList<String>(); ListView listView; ProgressDialog pDialog; //spinner new GetCategories().execute(); } // call to this from your java class. private class GetCategories extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(getActivity()); pDialog.setMessage("loading categories.."); pDialog.setCancelable(false); pDialog.show(); } @Override protected Void doInBackground(Void... arg0) { ServiceHandler jsonParser = new ServiceHandler(); String json2 = jsonParser.makeServiceCall(URL_PRODUCTS, ServiceHandler.GET); if (json2 != null) { try { JSONObject jsonObj = new JSONObject(json2); if (jsonObj != null) { JSONArray categories = jsonObj .getJSONArray("products"); for (int i = 0; i < categories.length(); i++) { JSONObject catObj = (JSONObject) categories.get(i); product_categoies.add(catObj.getString("type")); category_info.add("tap to open"); } } } catch (JSONException e) { System.out.println("Exception--- -- -- "+e.toString()); } } else { Log.e("JSON Data", "Didn't receive any data from server!"); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (pDialog.isShowing()) pDialog.dismiss(); setpropertise(); //post executing a method } } Manifest eke internet permission denna amathaka karannath epa <uses-permission android:name="android.permission.INTERNET"></uses-permission> // sorry machan..full code eka nam danna hatiyak na.. [/QUOTE]
Insert quotes…
Verification
Awruddata maasa keeyada?
Post reply
Top
Bottom