0

你能告诉我如何保存我最后的回调数据吗?我想离线使用它。感谢您阅读问候

public void onClick(View v) {

    final Double waluta_from_wartosc = Double.valueOf(editText_waluty.getText().toString());
    String from_waluta = String.valueOf(spinner_from.getSelectedItem());
    String to_waluta = String.valueOf(spinner_to.getSelectedItem());

    String url = base_url + "from=" + from_waluta + "&to=" + to_waluta;

    aq.ajax(url, JSONObject.class, new AjaxCallback<JSONObject>() {

        @Override
        public void callback(String url, JSONObject json, AjaxStatus status) {

            if (json != null) {

                try 
                {
                    Double rate = json.getDouble("rate");
                    double the_result = waluta_from_wartosc * rate;
                    textview_to.setText(String.valueOf(the_result) + " " + spinner_to.getSelectedItem().toString());
                 } 
                 catch (JSONException e) 
                 {
                     e.printStackTrace();
                 }
             } 
             else {
                 Toast.makeText(aq.getContext(), "BRAK DOSTĘPU DO INTERNETU!!!", Toast.LENGTH_SHORT).show();
4

1 回答 1

0

使用 Shared Preferences 或 SQLite db 来存储数据。通过这个

于 2016-08-11T12:48:05.620 回答