There is 2 activation code, they are the same with 1, but in the first spinner , and in the second ListView , and so in the first I have 1 Json in the spinner , I need to, when I click on an object in the spinner , the parsit is already out of 2 activations, but in ListView .

 public class MainActivity2 extends AppCompatActivity { private String TAG = MainActivity2.class.getSimpleName(); private ProgressDialog pDialog; private Spinner spinner; // URL to get contacts JSON private static String url = "Тут URL первого Json"; ArrayList<HashMap<String, String>> contactList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); contactList = new ArrayList<>(); spinner = (Spinner) findViewById(R.id.spinner); new GetContacts().execute(); } /** * Async task class to get json by making HTTP call */ private class GetContacts extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); // Showing progress dialog pDialog = new ProgressDialog(MainActivity2.this); pDialog.setMessage("Please wait..."); pDialog.setCancelable(false); pDialog.show(); } @Override protected Void doInBackground(Void... arg0) { HttpHandler sh = new HttpHandler(); // Making a request to url and getting response String jsonStr = sh.makeServiceCall(url); Log.e(TAG, "Response from url: " + jsonStr); if (jsonStr != null) { try { JSONObject jsonObj = new JSONObject(jsonStr); // Getting JSON Array node JSONArray data = jsonObj.getJSONArray("data"); // looping through All Contacts for (int i = 0; i < data.length(); i++) { JSONObject c = data.getJSONObject(i); String id = c.getString("id"); String ip = c.getString("ip"); String link = c.getString("link"); // tmp hash map for single contact HashMap<String, String> contact = new HashMap<>(); // adding each child node to HashMap key => value contact.put("id", id); contact.put("ip", ip); contact.put("link", link); // adding contact to contact list contactList.add(contact); } } catch (final JSONException e) { Log.e(TAG, "Json parsing error: " + e.getMessage()); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "Json parsing error: " + e.getMessage(), Toast.LENGTH_LONG) .show(); } }); } } else { Log.e(TAG, "Couldn't get json from server."); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "Couldn't get json from server. Check LogCat for possible errors!", Toast.LENGTH_LONG) .show(); } }); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); // Dismiss the progress dialog if (pDialog.isShowing()) pDialog.dismiss(); /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( MainActivity2.this, contactList, R.layout.list_item, new String[]{"ip", "link",}, new int[]{R.id.name, R.id.link}); spinner.setAdapter((SpinnerAdapter) adapter); } } } 
  • While the second activation is not visible on the screen, no ListView exists in nature. Describe in more detail what problem you need to solve, and not your [wrong] way of solving it, which causes natural problems. - pavlofff
  • Ok, I need to create a spinner in which the JSON parsit, when the list is opened, there you select an object, and it parses the other JSON , I hope you understand. - Shufler3
  • What is the interaction between activations? Do you select an item in the spinner and another activation should open, in which additional information on this item is displayed through the ListView or what? - pavlofff
  • Yes, that is exactly what I need) - Shufler3
  • Now, how are the data that the spinner receives with the data that the ListView should display? What is the sign of which JSON to receive for the list? - pavlofff

0