У меня есть внутренний класс, который расширяет 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;
}
}