Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>ok.. here is the entire code ...</p> <pre><code>public class Viewscores extends Activity{ Button scores; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.viewscores); scores = (Button) findViewById(R.id.bViewscores); scores.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { Intent i=new Intent(this,lst.class); startActivity(i); } }); } </code></pre> <p>here is the "lst" class</p> <pre><code>public class lst extends ListActivity{ JSONArray jArray; String result = null; InputStream is = null; StringBuilder sb=null; String s[]; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try{ URL u=new URL("http://deucalion0.co.uk/getscores.php"); URLConnection tc=u.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(tc.getInputStream())); String line; while ((line = reader.readLine()) != null) { jArray =new JSONArray(line); s=new String[jArray.length()]; for(int m=0;m&lt;jArray.length();m++){ JSONObject json_data=(JSONObject)jArray.get(m); s[m]=json_data.getInt("score")+" "+json_data.getString("username"); } } ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, s); setListAdapter(adapter); } catch(JSONException e1){ } catch (ParseException e1) { e1.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } | } --- </code></pre> <p>This one works for sure... try this... :)</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