Note that there are some explanatory texts on larger screens.

plurals
  1. POFragment implementing AsyncTask and Listview in android
    primarykey
    data
    text
    <p><strong>Here is my Java code</strong></p> <p>but it doesnt work i dont get my error. <img src="https://i.stack.imgur.com/q62b6.png" alt="Snpashot"></p> <pre><code>package info.androidhive.slidingmenu; import java.util.ArrayList; import java.util.HashMap; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.Fragment; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; public class CommunityFragment extends Fragment { public CommunityFragment(){} // Declare Variables JSONObject jsonobject; JSONArray jsonarray; ListView listview; ListViewAdapter adapter; ProgressDialog mProgressDialog; ArrayList&lt;HashMap&lt;String, String&gt;&gt; arraylist; static String RANK = "rank"; static String COUNTRY = "country"; static String POPULATION = "population"; static String FLAG = "flag"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_community, container, false); new DownloadJSON().execute(); return rootView; } // DownloadJSON AsyncTask private class DownloadJSON extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { super.onPreExecute(); // Create a progressdialog mProgressDialog = new ProgressDialog(CommunityFragment.this); // Set progressdialog title mProgressDialog.setTitle("Student Government App"); // Set progressdialog message mProgressDialog.setMessage("Loading..."); mProgressDialog.setIndeterminate(false); // Show progressdialog mProgressDialog.show(); } @Override protected Void doInBackground(Void... params) { // Create an array arraylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); // Retrieve JSON Objects from the given URL address jsonobject = JSONFunctions .getJSONfromURL("http://app-dlslsg.azurewebsites.net/json/postList.php"); try { // Locate the array name in JSON jsonarray = jsonobject.getJSONArray("post"); for (int i = 0; i &lt; jsonarray.length(); i++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); jsonobject = jsonarray.getJSONObject(i); // Retrive JSON Objects map.put("rank", jsonobject.getString("id")); map.put("country", jsonobject.getString("body")); map.put("population", jsonobject.getString("stamp")); map.put("flag", jsonobject.getString("image")); // Set the JSON Objects into the array arraylist.add(map); //Log.i("body",COUNTRY); } } catch (JSONException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void args) { // Locate the listview in listview_main.xml listview = (ListView) findViewById(R.id.listview); // Pass the results into ListViewAdapter.java adapter = new ListViewAdapter(CommunityFragment.this, arraylist); // Set the adapter to the ListView listview.setAdapter(adapter); // Close the progressdialog mProgressDialog.dismiss(); } } } </code></pre> <p>I tried searching all over the net today but i don't get a chance to see any related problems. Will someone help me to figure out this? i will reply asap on those responses <strong>advance thanks for help!</strong></p>
    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