Как использовать настраиваемый ArrayAdapter в отдельном классе?

У меня есть внутренний класс, расширяющий ArrayAdapter, чтобы настроить ListView. Я хотел бы разбить этот внутренний класс на отдельный файл, чтобы другие классы могли его использовать, но у них возникли проблемы с getLayoutInflater ().

По сути, мой метод getView () не знает, что такое getLayoutInflater (), хотя я расширяю ArrayAdapter. Кто-нибудь знает, как заставить это работать правильно?

Спасибо!

public class myDynAdap extends ArrayAdapter<String>
{
    String [] list;


   public myDynAdap (Context context, int textViewResourceId, String [] objects)
   {
       super (context, textViewResourceId, objects);
       mCtx = context;
       list = objects;
   }

    @Override
    public View getView (int position, View convertView, ViewGroup parent)
    {
        View row = convertView;

        if (row == null)
        {

            LayoutInflater inflater = getLayoutInflater ();  // <--- "The method getLayoutInflater() is undefined for the type myDynAdap"
            row = inflater.inflate (R.layout.main_listitem, parent, false);
        }

        TextView tv1 = (TextView) row.findViewById (R.id.tv_item);
        tv1.setBackgroundColor (Color.BLUE);

        // change background of 0th list element only
        if (position == 0)
            tv1.setBackgroundColor (Color.CYAN);

        return row;

    }
}
5
задан wufoo 5 August 2011 в 14:53
поделиться