AndroidAsyncHttp错误 [英] AndroidAsyncHttp Error

查看:324
本文介绍了AndroidAsyncHttp错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现循环J AndroidAsyncHttp的布伦特里项目。我下载的.jar文件并将其添加为一个库。

I'm trying to implement the LoopJ AndroidAsyncHttp for a Braintree project. I downloaded the .jar file and added it as a library.

我现在有以下code:

I now have the following code:

public class PayCharge extends Activity {

AsyncHttpClient client = new AsyncHttpClient();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.paycharge);



    client.get("https://xxx.herokuapp.com/generateToken.php", new TextHttpResponseHandler() {


        @Override
        public void onStart() {
            // Initiated the request
        }

        @Override
        public void onSuccess(String clientToken) {
            // Successfully got a response
        }

        @Override
        public void onFailure(String responseBody, Throwable e) {
            // Response failed :(
        }

        @Override
        public void onFinish() {
            // Completed the request (either success or failure)
        }



    });

}


}

不过,TextHtt presponseHandler()用下划线标出红色,出现以下错误:
班'从TextHtt presponseHandler()派生的匿名类'要么必须声明为抽象或实现抽象方法的onSuccess(INT,头[],字符串)在TextHtt presponseHandler

However, the TextHttpResponseHandler() part is underlined red with the following error: class 'Anonymous class derived from TextHttpResponseHandler()' must either be declared abstract or implement abstract method onSuccess(int, Header[], string) in TextHttpResponseHandler"

此外,双方的onSuccess和onFailure处@Override都强调红色声称该方法不从它的超覆盖。

Additionally, both of the onSuccess and onFailure @Override are underlined red claiming that the method does not override from its superclass.

我是初学者所以不太清楚如何进行。谢谢!

I'm a beginner so not quite sure how to proceed. Thanks!

推荐答案

如果让你的code一样的,你在你的问题已经和你改变的onSuccess你的方法签名(字符串clientToken) 的onSuccess(INT响应code,头[] responseHeaders响应,字符串responseBody)响应体将字符串的onSuccess 被调用。这将是你的客户令牌从你的服务器。

If keep your code the same as you have in your question and you change your method signature of onSuccess(String clientToken) to onSuccess(int responseCode, Header[] responseHeaders, String responseBody) the response body will be the String onSuccess is called with. This will be your client token from your server.

这篇关于AndroidAsyncHttp错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆