Java ArrayList哈希映射未定义

Java ArrayList哈希映射未定义,java,android,json,google-app-engine,arraylist,Java,Android,Json,Google App Engine,Arraylist,似乎无法理解为什么会出现此错误“ArrayList,int,String[],int[])未定义” 这是我的密码。其思想是从应用程序引擎数据存储中获取JSON,然后将其划分为列表视图 package com.indeeditis; public class FinderActivity extends ListActivity { private static final String TAG_ID = "id"; private static final String TAG

似乎无法理解为什么会出现此错误“
ArrayList,int,String[],int[])
未定义”

这是我的密码。其思想是从应用程序引擎数据存储中获取JSON,然后将其划分为列表视图

package com.indeeditis; 




public class FinderActivity extends ListActivity   {


private static final String TAG_ID = "id";
private static final String TAG_FIRSTNAME = "nameFirst";
private static final String TAG_LASTNAME = "nameLast";
private static final String TAG_EMAIL = "emailAddress";
private static final String TAG_ADDRESS = "address";
private static final String TAG_STATE = "state";

private static final String TAG_PHONE = "phone";
JSONArray contacts = null;

ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.finder);

   // Button start = (Button)findViewById(R.id.button9000);
    //start.setOnClickListener(this);
    new EndpointsTask().execute(getApplicationContext());

}



public class EndpointsTask extends AsyncTask<Context, Integer, Long> {

    public Long doInBackground(Context... contexts) {

      Contactinfoendpoint.Builder endpointBuilder = new Contactinfoendpoint.Builder(
          AndroidHttp.newCompatibleTransport(),
          new JacksonFactory(),
          new HttpRequestInitializer() {
          public void initialize(HttpRequest httpRequest) { }
          });
  Contactinfoendpoint endpoint = CloudEndpointUtils.updateBuilder(
  endpointBuilder).build();

  try {

     // final TextView detail = (TextView)findViewById(R.id.textView100);

    String apples = endpoint.listContactInfo().execute().toString();

    JSONObject jObject = new JSONObject(apples);

           try{
        //Get the element that holds the earthquakes ( JSONArray )
        JSONArray  contacts = jObject.getJSONArray("item");

        for(int i = 0; i < contacts.length(); i++){
            JSONObject c = contacts.getJSONObject(i);

            // Storing each json item in variable
            String id = c.getString(TAG_ID);
            String nameFirst = c.getString(TAG_FIRSTNAME);
            String nameLast = c.getString(TAG_LASTNAME);
            String email = c.getString(TAG_EMAIL);
            String address = c.getString(TAG_ADDRESS);
            String phone = c.getString(TAG_PHONE);

            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();

            // adding each child node to HashMap key => value
            map.put(TAG_ID, id);
            map.put(TAG_FIRSTNAME, nameFirst);
            map.put(TAG_EMAIL, email);
            map.put(TAG_PHONE, phone);

            // adding HashList to ArrayList
            contactList.add(map);



        }

           }catch(JSONException e)        {
             Log.e("log_tag", "Error parsing data "+e.toString());
           }


             // THE ERROR IS RIGHT HERE TO
           ListAdapter adapter = new SimpleAdapter(this, contactList,
                    R.layout.main,
                    new String[] { TAG_FIRSTNAME, TAG_EMAIL, TAG_PHONE }, new int[] {
                            R.id.nameFirst, R.id.email, R.id.mobile });
           //HERE
           setListAdapter(adapter);

            // selecting single ListView item
            ListView lv = getListView();

  } catch (IOException e) {
    e.printStackTrace();
  } catch (JSONException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
      return (long) 0;
    }


    }

}
package com.indeditis;
公共类FinderActivity扩展了ListActivity{
私有静态最终字符串标记\u ID=“ID”;
私有静态最终字符串标记_FIRSTNAME=“nameFirst”;
私有静态最终字符串标记_LASTNAME=“nameLast”;
私有静态最终字符串标记\u EMAIL=“emailAddress”;
私有静态最终字符串标记_ADDRESS=“ADDRESS”;
私有静态最终字符串标记_STATE=“STATE”;
专用静态最终字符串标记_PHONE=“PHONE”;
JSONArray联系人=null;
ArrayList contactList=新建ArrayList();
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.finder);
//按钮开始=(按钮)findViewById(R.id.button9000);
//start.setOnClickListener(this);
新建EndpointsTask().execute(getApplicationContext());
}
公共类EndpointsTask扩展异步任务{
公共长文档背景(上下文…上下文){
Contactinfoendpoint.Builder endpointBuilder=新建Contactinfoendpoint.Builder(
AndroidHttp.newCompatibleTransport(),
新JacksonFactory(),
新的HttpRequestInitializer(){
公共无效初始化(HttpRequest HttpRequest){}
});
Contactinfoendpoint=CloudEndpointUtils.updateBuilder(
endpointBuilder.build();
试一试{
//最终TextView详细信息=(TextView)findViewById(R.id.textView100);
字符串apples=endpoint.listContactInfo().execute().toString();
JSONObject jObject=新的JSONObject(苹果);
试一试{
//获取保存地震的元素(JSONArray)
JSONArray contacts=jObject.getJSONArray(“项目”);
对于(int i=0;ivalue
地图放置(标签标识,标识);
map.put(TAG_FIRSTNAME,nameFirst);
地图放置(标签、电子邮件、电子邮件);
地图放置(标签电话,电话);
//将哈希列表添加到ArrayList
联系人列表。添加(地图);
}
}捕获(JSONException e){
Log.e(“Log_标记”,“错误解析数据”+e.toString());
}
//错误就在这里
ListAdapter=新的SimpleAdapter(此,contactList,
R.layout.main,
新字符串[]{TAG_FIRSTNAME,TAG_EMAIL,TAG_PHONE},新int[]{
R.id.nameFirst、R.id.email、R.id.mobile});
//这里
setListAdapter(适配器);
//选择单个ListView项
ListView lv=getListView();
}捕获(IOE异常){
e、 printStackTrace();
}捕获(JSONException e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
返回(长)0;
}
}
}

SimpleAdapter
只有一个


其中
不是
上下文
,而是对
EndpointsTask
实例的引用。使用
FinderActivity。如果
EndpointsTask
FinderActivity

SimpleAdapter
的一个内部类,则使用该类

其中
不是
上下文
,而是对
EndpointsTask
实例的引用。使用
FinderActivity。如果
EndpointsTask
是Android文档中的
FinderActivity

的内部类,则使用
FinderActivity

public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int 
      resource, String[] from, int[] to)

Added in API level 1

Constructor
Parameters
context     The context where the View associated with this SimpleAdapter 
            is running

data        A List of Maps. Each entry in the List corresponds to one row 
            in the list. The Maps contain the data for each row, and should 
            include all the entries specified in "from"

resource    Resource identifier of a view layout that defines the views for this 
            list item. The layout file should include at least those named views
            defined in "to"

from        A list of column names that will be added to the Map associated with 
            each item.

to          The views that should display column in the "from" parameter. 
            These should all be TextViews. The first N views in this list are 
            given the values of the first N columns in the from parameter. 
publicsimpledapter(上下文,列表>数据,int
资源,字符串[]从,int[]到)
在API级别1中添加
建造师
参数
上下文与此SimpleAdapter关联的视图所在的上下文
正在运行
地图列表中的数据。列表中的每个条目对应一行
在名单上。映射包含每行的数据,并且应该
包括“发件人”中指定的所有条目
定义此视图的视图的视图布局的资源标识符
列表项。布局文件应至少包括那些命名视图
定义在“to”中
从将添加到与关联的映射的列名列表中
每一项。
到“from”参数中应显示列的视图。
这些都应该是文本视图。此列表中的前N个视图是
给定from参数中前N列的值。
但是在您的代码中,根据构造函数的规范,这不是上下文

使用
查找活动。此
。它将在Android文档中运行

public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int 
      resource, String[] from, int[] to)

Added in API level 1

Constructor
Parameters
context     The context where the View associated with this SimpleAdapter 
            is running

data        A List of Maps. Each entry in the List corresponds to one row 
            in the list. The Maps contain the data for each row, and should 
            include all the entries specified in "from"

resource    Resource identifier of a view layout that defines the views for this 
            list item. The layout file should include at least those named views
            defined in "to"

from        A list of column names that will be added to the Map associated with 
            each item.

to          The views that should display column in the "from" parameter. 
            These should all be TextViews. The first N views in this list are 
            given the values of the first N columns in the from parameter. 
publicsimpledapter(上下文,列表>数据,int
资源,字符串[]从,int[]到)
在API级别1中添加
建造师
参数
上下文与此SimpleAdapter关联的视图所在的上下文
正在运行
地图列表中的数据。列表中的每个条目对应一行
在名单上。映射包含每行的数据,并且应该
包括“发件人”中指定的所有条目
定义此视图的视图的视图布局的资源标识符
列表项。布局文件应至少包括那些命名视图
定义在“to”中
从一个l
new SimpleAdapter(this, // not a Context
                contactList, // List
                R.layout.main, // int
                new String[] { TAG_FIRSTNAME, TAG_EMAIL, TAG_PHONE }, // String[]
                new int[] {R.id.nameFirst, R.id.email, R.id.mobile }); // int[]
public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int 
      resource, String[] from, int[] to)

Added in API level 1

Constructor
Parameters
context     The context where the View associated with this SimpleAdapter 
            is running

data        A List of Maps. Each entry in the List corresponds to one row 
            in the list. The Maps contain the data for each row, and should 
            include all the entries specified in "from"

resource    Resource identifier of a view layout that defines the views for this 
            list item. The layout file should include at least those named views
            defined in "to"

from        A list of column names that will be added to the Map associated with 
            each item.

to          The views that should display column in the "from" parameter. 
            These should all be TextViews. The first N views in this list are 
            given the values of the first N columns in the from parameter.