Note that there are some explanatory texts on larger screens.

plurals
  1. POListFragments - unable to display list
    primarykey
    data
    text
    <p>I am using navigation drawer with action bar sherlock fragments.I am having one main activity and calling four fragments from there. In one of those fragments, need to display list of products. I am able to fetch and parse json data successfully. But, not able to display list in my layout. in logcat, till 'In thread' is getting displayed. after that, app crashes.</p> <pre><code> class LoadEnq extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(getActivity()); pDialog.setMessage("Listing Enquiries ..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /** * getting Albums JSON * */ protected String doInBackground(String... args) { // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("TOKEN", "INBOX-S!U@B#O$")); params.add(new BasicNameValuePair("ACTION", "inbox")); params.add(new BasicNameValuePair("MODID", "IMOB")); params.add(new BasicNameValuePair("GLID", "423104")); params.add(new BasicNameValuePair("FOLDER", "1")); params.add(new BasicNameValuePair("FROM", "0")); params.add(new BasicNameValuePair("TO", "500")); // getting JSON string from URL String json = jsonParser.makeHttpRequest(URL_ENQ, "POST", params); // Check your log cat for JSON reponse Log.d("Enq JSON: ", "&gt; " + json); try { System.out.println("in try"); enq = new JSONArray(json); if (enq != null) { // looping through All albums for (int i = 0; i &lt; enq.length(); i++) { JSONObject c = enq.getJSONObject(i); // Storing each json item values in variable String qid = c.getString(TAG_QID); String qtype = c.getString(TAG_QTYPE); String name = c.getString(TAG_SNAME); String email = c.getString(TAG_SEMAIL); String subject = c.getString(TAG_SUBJECT); System.out.println("QID" + qid); // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); // adding each child node to HashMap key =&gt; value map.put(TAG_QID, qid); map.put(TAG_QTYPE, qtype); map.put(TAG_SNAME, name); map.put(TAG_SEMAIL, email); map.put(TAG_SUBJECT, subject); // adding HashList to ArrayList enqList.add(map); } }else{ Log.d("Enquries: ", "null"); } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { System.out.println("post"); // dismiss the dialog after getting all albums pDialog.dismiss(); System.out.println("dismiss"); // updating UI from Background Thread //getActivity().runOnUiThread(new Runnable() { //public void run() { System.out.println("in thread"); /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( getActivity(), enqList, R.layout.list_item_albums, new String[] { TAG_QID,TAG_QTYPE, TAG_SNAME, TAG_SEMAIL,TAG_SUBJECT }, new int[] { R.id.query_id,R.id.qtype ,R.id.name,R.id.email, R.id.subject }); //adapter.notifyDataSetChanged(); // updating listview setListAdapter(adapter); //} //}); } } </code></pre> <p>}</p> <p>StackTrace:</p> <pre><code>07-09 12:21:02.374: E/AndroidRuntime(482): FATAL EXCEPTION: main 07-09 12:21:02.374: E/AndroidRuntime(482): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(16908298, class android.widget.ListView) with Adapter(class android.widget.SimpleAdapter)] 07-09 12:21:02.374: E/AndroidRuntime(482): at android.widget.ListView.layoutChildren(ListView.java:1492) 07-09 12:21:02.374: E/AndroidRuntime(482): at android.widget.AbsListView.onLayout(AbsListView.java:1147) 07-09 12:21:02.374: E/AndroidRuntime(482): at android.view.View.layout(View.java:7035) 07-09 12:21:02.374: E/AndroidRuntime(482): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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