预期此令牌后令牌variabledeclaratorid语法错误

预期此令牌后令牌variabledeclaratorid语法错误

本文介绍了预期此令牌后令牌variabledeclaratorid语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时得到以下行在此令牌后,预计令牌variabledeclaratorid语法错误

  listAq =新AQuery(本);

下面是我的全code

 包com.example.test;进口org.json.JSONObject;进口android.app.Activity;
进口android.os.Bundle;
进口android.widget.ArrayAdapter;进口com.androidquery.AQuery;公共类测试活动扩展了活动{    私人AQuery水溶液;    @覆盖
    公共无效的onCreate(捆绑savedInstanceState){            super.onCreate(savedInstanceState);
            的setContentView(R.layout.activity_main);    }    listAq =新AQuery(本);    ArrayAdapter<&JSONObject的GT; AA =新ArrayAdatper<&JSONObject的GT;(这一点,R.layout.activity_main,物品){
        @覆盖        公共查看getView(INT位置,查看convertView,父母的ViewGroup){            如果(convertView == NULL){
            convertView = getLayoutInflater()膨胀(R.layout.activity_main,NULL);
            }            JSONObject的乔=的getItem(位置);            AQuery AQ = listAq.recycle(convertView);
            aq.id(R.id.name)的.text(jo.optString(titleNoFormating,无题));
            aq.id(R.id.meta)的.text(jo.optString(发行人,));            字符串TB = jo.optJSONObject(图像)optString(tbUrl);
            aq.id(R.id.tb).progress(R.id.progress)在图像配(TB,真实的,真实的,0,0,空,AQuery.FADE_IN_NETWORK,1.0F);
            返回convertView;
        }
    };}


解决方案

移动这里面的onCreate

  AQuery listAq =新AQuery(本);
 ArrayAdapter<&JSONObject的GT; AA =新ArrayAdatper<&JSONObject的GT;(这一点,R.layout.activity_main,物品){
 ....

Im getting "syntax error on token variabledeclaratorid expected after this token" on the following line

  listAq = new AQuery(this);

Here is my full 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, true,0,0,null,AQuery.FADE_IN_NETWORK,1.0f);
            return convertView;
        }
    };



}
解决方案

Move this inside onCreate

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

这篇关于预期此令牌后令牌variabledeclaratorid语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:12