嗨,我正在制作货币转换器
我已经完成了这部分...我正在获取 JSON 文件,我可以在 LOGCAT 上看到它...现在我的问题是如何让 JSON 将其转换为字符串并将其解析为 float/double 到让我能够操纵它们...
这是到目前为止的代码
import com.actionbarsherlock.app.SherlockActivity;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends SherlockActivity {
private static final String API_URL = "my own api";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnConvert = (Button)findViewById(R.id.buttonConvert);
btnConvert.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AsyncHttpClient client = new AsyncHttpClient();
client.get(API_URL, new AsyncHttpResponseHandler() {
@Override
public void onFailure(Throwable arg0, String arg1) {
// TODO Auto-generated method stub
super.onFailure(arg0, arg1);
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
super.onFinish();
}
@Override
public void onStart() {
// TODO Auto-generated method stub
super.onStart();
}
@Override
public void onSuccess(String response) {
Log.i("CC", response);
}
});
}
});
}
}
我现在真的很迷茫,最后期限就在我家门口