在我的应用程序中,我使用列表视图并通过扩展标准数组适配器自定义了关联的数组适配器。但是,在扩展适配器内部,我无法将视图保持器声明为静态内部类。Eclipse 不断给出“静态类型只能在静态或顶级类型中声明”的错误。这是代码:
public class IconicAdapter extends ArrayAdapter<String>
{
public static class ViewHolder
{
public TextView text;
public ImageView image;
}
public IconicAdapter() {
super(MainActivity.this,R.layout.row,values);
// TODO Auto-generated constructor stub
}
public View getView(int position,View convertView, ViewGroup parent)
{
View row = convertView;
if(row == null)
{
LayoutInflater inflater = getLayoutInflater();
row = inflater.inflate(R.layout.row, parent,false);
}
TextView label =(TextView)row.findViewById(R.id.label);
label.setText(values[position]);
ImageView icon = (ImageView)row.findViewById(R.id.icon);
icon.setImageResource(R.drawable.ok);
return (row);
}
}
有什么建议吗?