コード例 #1
0
  public void submitOnClick(View view) { // called when user clicks submit
    String getRapLeafRequest = getRapLeafRequest();
    try {
      JSONObject jsonobject =
          new JSONObject(getRapLeafRequest); // stores the response as a JSON object
      String resultString = jsonobject.toString(); // converts it to a string
      resultString =
          resultString.substring(
              1, resultString.length() - 2); // parses the information so it can be viewed easier
      resultString = resultString.replace('"', ' ');
      resultString = resultString.replaceAll(",", "\n");
      TextView results = (TextView) findViewById(R.id.results);
      results.setText(resultString);

      Log.v(DEBUG_TAG, jsonobject.toString());
      // }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }