构造函数ArrayAdapter< ArrayList的< HashMap的<字符串,字符串>>>(上下文,INT的ArrayList< HashMap的<字符串,字符串>>)的不确定 [英] The constructor ArrayAdapter<ArrayList<HashMap<String, String>>>(Context, int, ArrayList<HashMap<String, String>>) is undefined

查看:312
本文介绍了构造函数ArrayAdapter< ArrayList的< HashMap的<字符串,字符串>>>(上下文,INT的ArrayList< HashMap的<字符串,字符串>>)的不确定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是全新到Android。

此问题可能是一个基本的。

不过,我挣扎了四天与此有关。请帮帮我。

我正在做的ListView水平从博客提供几个类别的内容。

(带脉冲新闻应用程序类似的界面)

我的水平列表视图的开源和我修改它。

这code是 CustomArrayAdapter.java

但是,当我尝试写超();在构造函数中,它使一个错误是这样的:

 构造ArrayAdapter< ArrayList的< HashMap的<字符串,字符串>>>(上下文,INT的ArrayList< HashMap的<字符串,字符串>>)的不确定

和月蚀意味着这样的:

 删除参数匹配'ArrayAdapter< ArrayList的<&HashMap的LT;字符串,字符串>>>(上下文,INT)

我不知道这个(背景下,INT)的说法是从哪里来的。

请检查什么是错的 CustomArrayAdapter.java 如下:

 包com.xxxx.xxxxxxxxx;进口的java.util.ArrayList;
进口的java.util.HashMap;进口android.content.Context;
进口android.graphics.Color;
进口android.view.LayoutInflater;
进口android.view.View;
进口android.view.ViewGroup;
进口android.widget.ArrayAdapter;
进口android.widget.ImageView;
进口android.widget.TextView;/ **,知道的CustomData给出类时如何呈现的观点数组适配器* /
公共类CustomArrayAdapter扩展ArrayAdapter< ArrayList的<&HashMap的LT;字符串,字符串>>> {
    私人上下文的背景下;
    私人的ArrayList<&HashMap的LT;字符串,字符串>>数据;
    私人诠释viewId;    私人LayoutInflater mInflater;    公共CustomArrayAdapter(上下文C中,int textViewResourceId,ArrayList的<&HashMap的LT;字符串,字符串> D 1和D){
        超(C,textViewResourceId,D);        this.context = C;
        this.viewId = textViewResourceId;
        this.data = D;
    }     @覆盖
     公众诠释的getCount(){
         返回data.size();
     }    / *
     *我们在这里重写getView方法 - 这是什么定义了每个
     *列表项的外观。
     * /
    @覆盖
    公共查看getView(INT位置,查看convertView,父母的ViewGroup){
        //指定我们正在转换到一个局部变量视图
        查看VI = convertView;
        持有人持有人;        如果(convertView == NULL){            //充气视图,因为它不存在
            如果(六== NULL){
                mInflater =(LayoutInflater)的getContext()getSystemService(Context.LAYOUT_INFLATER_SERVICE)。
                VI = mInflater.inflate(R.layout.custom_data_view,NULL);
            }            / *
             *回想一下,可变位置发送作为参数传递给这个方法。
             *变量仅仅是指列表中的当前物体的位置。 (一个ArrayAdapter
             *遍历列表我们给它)
             *
             *所以,我指的是目前的项目对象。
             * /            //这是你如何获得对TextViews的参考。
            //这些TextViews在我们定义的XML文件创建的。            //创建并保存了持有人的标签,所以我们可以快速进入内场
            //这必须出于性能方面的工作要做            持有人=新的持有人();
            holder.textView =(TextView中)vi.findViewById(R.id.title_view);
            holder.imageView =(ImageView的)vi.findViewById(R.id.thumbnail_view);            vi.setTag(保持器);        }其他{
            支架=(座)vi.getTag();
        }        //检查,看看是否每一个人的TextView为空。
        //如果没有,分配一些文字!
        //填充文本        HashMap的<字符串,字符串> CURRENTDATA =新的HashMap<字符串,字符串>();
        CURRENTDATA = data.get(位置);        如果(CURRENTDATA!= NULL){
            holder.textView.setText(currentData.get(MainActivity.KEY_TITLE));
            holder.imageLoader =新ImageLoader的(context.getApplicationContext());
            holder.imageLoader.DisplayImage(currentData.get(MainActivity.KEY_THUMBNAIL),holder.imageView);
        }        //设置颜色
        vi.setBackgroundColor(Color.DKGRAY);
        返回VI;
    }    / **因为我们需要访问*视图查看架/
    私有静态类持有人{
        公众的TextView的TextView;
        公共ImageView的ImageView的;
        公共ImageLoader的ImageLoader的;
    }
}


解决方案

它应该是:

 公共类CustomArrayAdapter扩展ArrayAdapter<&HashMap的LT;字符串,字符串>>

I am totally new to Android.

This question might be a basic one.

But I'm struggling for four days with this. Please Help me.

I'm making horizontal listview for providing the contents of several categories from blog.

(similar interface with Pulse news app)

I got the open source of the horizontal listview and I'm modifying it.

This code is CustomArrayAdapter.java.

But when I try to write super(); inside the constructor, it makes an error like this :

The constructor ArrayAdapter<ArrayList<HashMap<String, String>>>(Context, int, ArrayList<HashMap<String, String>>) is undefined

And eclipse suggests like this :

Remove argument to match 'ArrayAdapter<ArrayList<HashMap<String, String>>>(Context, int)'

I don't know where this (Context, int) argument came from.

Please check what is wrong in CustomArrayAdapter.java below :

package com.xxxx.xxxxxxxxx;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/** An array adapter that knows how to render views when given CustomData classes */
public class CustomArrayAdapter extends ArrayAdapter<ArrayList<HashMap<String, String>>> {
    private Context context;
    private ArrayList<HashMap<String, String>> data;
    private int viewId;

    private LayoutInflater mInflater;

    public CustomArrayAdapter(Context c, int textViewResourceId, ArrayList<HashMap<String, String>> d) {
        super(c, textViewResourceId, d);

        this.context = c;
        this.viewId = textViewResourceId;
        this.data = d; 
    }

     @Override
     public int getCount() {
         return data.size();
     }

    /*
     * We are overriding the getView method here - this is what defines how each
     * list item will look.
     */
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {         
        // Assign the view we are converting to a local variable
        View vi = convertView;
        Holder holder;      

        if (convertView == null) {

            // Inflate the view since it does not exist
            if (vi == null) {
                mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                vi = mInflater.inflate(R.layout.custom_data_view, null);
            }

            /*
             * Recall that the variable position is sent in as an argument to this method.
             * The variable simply refers to the position of the current object in the list. (The ArrayAdapter
             * iterates through the list we sent it)
             * 
             * Therefore, i refers to the current Item object.
             */

            // This is how you obtain a reference to the TextViews.
            // These TextViews are created in the XML files we defined.

            // Create and save off the holder in the tag so we get quick access to inner fields
            // This must be done for performance reasons

            holder = new Holder();
            holder.textView = (TextView) vi.findViewById(R.id.title_view);
            holder.imageView = (ImageView) vi.findViewById(R.id.thumbnail_view);

            vi.setTag(holder);                                  

        } else {
            holder = (Holder) vi.getTag();
        }

        // check to see if each individual textview is null.
        // if not, assign some text!
        // Populate the text 

        HashMap<String, String> currentData = new HashMap<String, String>();
        currentData = data.get(position);

        if (currentData != null) {
            holder.textView.setText(currentData.get(MainActivity.KEY_TITLE));
            holder.imageLoader = new ImageLoader(context.getApplicationContext());    
            holder.imageLoader.DisplayImage(currentData.get(MainActivity.KEY_THUMBNAIL), holder.imageView);
        }       

        // Set the color
        vi.setBackgroundColor(Color.DKGRAY);
        return vi;
    }

    /** View holder for the views we need access to */
    private static class Holder {
        public TextView textView;
        public ImageView imageView;
        public ImageLoader imageLoader;
    }
}

解决方案

It should be:

public class CustomArrayAdapter extends ArrayAdapter<HashMap<String, String>>

这篇关于构造函数ArrayAdapter&LT; ArrayList的&LT; HashMap的&LT;字符串,字符串&GT;&GT;&GT;(上下文,INT的ArrayList&LT; HashMap的&LT;字符串,字符串&GT;&gt;)的不确定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆