Cannot declare ViewHolder a static inner class.

In my application, I use listview and configured the associated array adapter, expanding the array adapter standard. However, inside the extended adapter, I cannot declare the viewer as a static inner class. Eclipse continues to give the error that "static types can only be declared at the static or top level." Here is the code:

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); } } 

Any suggestion?

+3
source share
1 answer

If the IconicAdapter is an inner class, you cannot declare an inner static class inside it unless the IconicAdapter is declared as a static class.

+8
source

All Articles