Did you import it in your class?

import com.android.volley.toolbox.JsonObjectRequest;

The easier way is to use the menu option "Code/Optimize Imports" or the
shorcut available on your operative system.

You will also need to add the dependency to your build.gradle file:

compile 'com.android.volley:volley:1.0.0'


Or whatever is the newest version number.

Marina

On Mon, Jan 9, 2017 at 10:39 AM, Alex <alexandermiller4...@gmail.com> wrote:

> Hi,
>
> I am trying to retrieve a JSON query. I am a beginner so I have copied and
> pasted the below model code from https://developer.android.com/
> training/volley/request.html. In android studio every JsonObjectRequest
> is being highlighted red with the hover-over error message "Can not resolve
> symbol 'JsonObjectRequest'. Please can you tell me how to fix? Thank you
>
> TextView mTxtDisplay;
>
> ImageView mImageView;
> mTxtDisplay = (TextView) findViewById(R.id.txtDisplay);
> String url = "http://my-json-feed";;
>
> JsonObjectRequest jsObjRequest = new JsonObjectRequest
>         (Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
>
>     @Override
>     public void onResponse(JSONObject response) {
>         mTxtDisplay.setText("Response: " + response.toString());
>     }
> }, new Response.ErrorListener() {
>
>     @Override
>     public void onErrorResponse(VolleyError error) {
>         // TODO Auto-generated method stub
>
>     }
> });
>
> // Access the RequestQueue through your singleton class.
> MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/android-developers/a2114256-7ab0-4092-a5a3-
> 782a57e11f2e%40googlegroups.com
> <https://groups.google.com/d/msgid/android-developers/a2114256-7ab0-4092-a5a3-782a57e11f2e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CACaNmX0RsCmWZMot4MQHCfGVkaUgeW0Ws-Rt_46XA2%2BvGP%3D01A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to