Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting a listview from sql with json
    primarykey
    data
    text
    <p>iv been having trouble trying to set a listview from a json object from mySQL, iv given internet permission i have working item_list files, so here is my code to check out</p> <pre><code>public class MainActivity extends ListActivity { String result = ""; InputStream is = null; String storyNames = ""; //String[] STORYLIST = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.menu_list); returnJson(); String[] STORYLIST = new Gson().fromJson(result,String[].class); setListAdapter (new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, STORYLIST)); ListView menulist = getListView(); menulist.setTextFilterEnabled(true); menulist.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { if (position == 0) { // Intent buttona = new Intent(view.getContext(), OneActivity.class); // startActivity(buttona); } if (position == 1) { // Intent buttonb = new Intent(view.getContext(), TwoActivity.class); // startActivity(buttonb); } if (position == 2) { // Intent buttonc = new Intent(view.getContext(), ThreeActivity.class); // startActivity(buttonc); } if (position == 3) { //Intent buttond = new Intent(view.getContext(), FourActivity.class); //startActivity(buttond); } } }); //end of oncreate() } public void returnJson(){ //TextView one = (TextView) findViewById(R.id.textView1); try{ HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://10.0.2.2/textures_story_list.php"); HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); is = entity.getContent(); }catch(Exception e) { // one.setText("error3"); } try{ BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result = sb.toString(); }catch(Exception e) { // one.setText("error2"); } try{ JSONArray jArray = new JSONArray(result); String storyNames = ""; for(int i = 0;i&lt;jArray.length();i++){ // storyNames += jArray.getJSONObject(i).getString("story_name") + "\n"; } // one.setText(storyNames); } catch(JSONException e) { // one.setText("error1"); } return; //end of returnJson() } //end of class body } </code></pre> <p>i think the problem is with setListAdapter or String[] STORYLIST</p> <p>can someone please help with whats going wrong?</p>
    singulars
    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.
    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