queue.start();错误:预期为<identifier>

时间:2018-08-07 14:56:11

标签: android

我的代码:

private TextView mTextMessage;
RequestQueue queue = Volley.newRequestQueue(this);
String url ="http://www.google.com";

// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                // Display the first 500 characters of the response string.
                mTextMessage.setText("Response is: "+ response.substring(0,500));
            }
        }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
        mTextMessage.setText("That didn't work!");
    }
});

// Add the request to the RequestQueue.
queue.start();

我引用此文件。 https://developer.android.com/training/volley/requestqueue

错误消息是
queue.start(); error: <identifier> expected
为什么?

0 个答案:

没有答案