title: How to validate a json array with edittext
body: <p>Here is my android code, I want to validate the pincode which I fetch from the json, so I have added an <code>EditText</code> and <code>Button</code>, but I dont know where to implement and how to implement.</p>
  
  <p>As per the following code, I get a bunch of pincode from the json file and it prints on a <code>ListView</code>. Now there will be a <code>EditText</code> and a <code>Button</code>, when I put any pincode which I fetched, it should give me a toast with <code>true</code> or <code>false</code>.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private String TAG = MainActivity.class.getSimpleName();
  
      private ProgressDialog pDialog;
      private ListView lv;
  
      Button bt;
      EditText et;
  
      private static String url = "http://52.206.14.188:8080/Configuration";
  
      ArrayList&lt;HashMap&lt;String, ArrayList&lt;String&gt;&gt;&gt; contactList;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          contactList = new ArrayList&lt;HashMap&lt;String, ArrayList&lt;String&gt;&gt;&gt;();
  
          lv = (ListView) findViewById(R.id.list);
  
           bt = (Button)findViewById(R.id.check);
           et = (EditText)findViewById(R.id.val);
  
          new GetContacts().execute();
      }
  
      private class GetContacts extends AsyncTask&lt;Void, Void, Void&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              // Showing progress dialog
              pDialog = new ProgressDialog(MainActivity.this);
              pDialog.setMessage("Please wait...");
              pDialog.setCancelable(false);
              pDialog.show();
  
          }
  
          @Override
          protected Void doInBackground(Void... arg0) {
              HttpHandler sh = new HttpHandler();
  
              String jsonStr = sh.makeServiceCall(url);
  
              Log.e(TAG, "Response from url: " + jsonStr);
  
              if (jsonStr != null) {
                  try {
  
                      JSONArray Source = new JSONArray(jsonStr);
                      JSONObject config = Source.getJSONObject(6);
                      JSONObject configVal = new JSONObject(config.getString("configurationVal"));
                      JSONArray areas = configVal.getJSONArray("availableAreas");
                      ArrayList&lt;String&gt; pincodes = new ArrayList&lt;String&gt;();
                      for (int i = 0 ; i &lt; areas.length(); i++) {
                          JSONObject area = areas.getJSONObject(i);
                          pincodes.add(area.getString("pincode"));
  
                          HashMap&lt;String, ArrayList&lt;String&gt;&gt; contact = new HashMap&lt;&gt;();
                          contact.put("pincode", pincodes);
                          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();
                          }
                      });
  
                  }
              }
  
              return null;
  
          }
  
          @Override
          protected void onPostExecute(Void result) {
              super.onPostExecute(result);
              if (pDialog.isShowing())
                  pDialog.dismiss();
  
              ListAdapter adapter = new SimpleAdapter(
                      MainActivity.this, contactList,
                      R.layout.list_item, new String[]{"pincode"}, new int[]{R.id.title});
              lv.setAdapter(adapter);
          }
      }
  }
  </code></pre>