Hi!
I have this DownloadJSON class initialized on onCreate with
Below, depending where users clicks, I want to change
Something like this:
How I can obtain this? I can't figure out how to do it.
Thanks!
I have this DownloadJSON class initialized on onCreate with
Java:
new DownloadJSON().execute();
Java:
@Override
protected Void doInBackground(Void... params) {
arraylist = new ArrayList<HashMap<String, String>>();
jsonobject = JSONfunctions.getJSONfromURL("http://www.domain.com/json2.txt");
try {
jsonarray = jsonobject.getJSONArray("worldpopulation");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
map.put("rank", jsonobject.getString("rank"));
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;Below, depending where users clicks, I want to change jsonobject = JSONfunctions.getJSONfromURL("http://www.domain.com/json1.txt");
Something like this:
}
@Override
protected void onPostExecute(Void args) {
listview = (ListView) findViewById(R.id.listview);
adapter = new ListViewAdapter(MainActivity.this, arraylist);
listview.setAdapter(adapter);
}
}
Below, depending where users clicks, I want to change
Java:
jsonobject = JSONfunctions.getJSONfromURL("http://www.domain.com/json1.txt");
Something like this:
Java:
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.itemone) {
new DownloadJSON().execute("http://www.domain.com/json2.txt");
}
else if (id == R.id.itemtwo) {
new DownloadJSON().execute("http://www.domain.com/json3.txt");
}
return true;
}
How I can obtain this? I can't figure out how to do it.
Thanks!