Java – syntax error on the expected token variabledeclaratorid after this token

In the next line, I get "syntax error of the expected token variable declaration after this token"

listAq = new AQuery(this);

This is my complete code

package com.example.test;

import org.json.JSONObject;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

import com.AndroidQuery.AQuery;

public class TestActivity extends Activity {



    private AQuery aq;

    @Override
    public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);



    }

    listAq = new AQuery(this);

    ArrayAdapter<JSONObject> aa = new ArrayAdatper<JSONObject>(this,R.layout.activity_main,items){


        @Override

        public View getView(int position,View convertView,ViewGroup parent){

            if(convertView == null){
            convertView = getLayoutInflater().inflate(R.layout.activity_main,null);
            }

            JSONObject jo = getItem(position);

            AQuery aq = listAq.recycle(convertView);
            aq.id(R.id.name).text(jo.optString("titleNoFormating","No Title"));
            aq.id(R.id.Meta).text(jo.optString("publisher",""));

            String tb = jo.optJSONObject("image").optString("tbUrl");
            aq.id(R.id.tb).progress(R.id.progress).image(tb,true,null,AQuery.FADE_IN_NETWORK,1.0f);
            return convertView;
        }
    };



}

Solution

Move it to oncreate

AQuery listAq = new AQuery(this);
 ArrayAdapter<JSONObject> aa = new ArrayAdatper<JSONObject>(this,items){
 ....
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>