Mam następujące ostrzeżenie:Niestandardowy widok brakuje konstruktora używany przez narzędzia do adaptera
widok klienta com/example/view/adapter/SomeAdapter brakuje konstruktora używany przez narzędzia: (kontekstu) lub (Context , AttributeSet) lub (Context, AttributeSet, int)
w mojej klasie SomeAdapter która rozciąga się trochę BaseAdapter która rozciąga ArrayAdapter
public class SomeAdapter extends BaseAdapter{}
public abstract class BaseAdapter extends ArrayAdapter<SomeModel>{}
Ostrzeżenie występuje w betonie, ale nie w abstrakcyjnym BaseAdapter. Czy ktoś kiedykolwiek słyszał o tym ostrzeżeniu w tym kontekście?
AFAIK Android sprawdza zajęcia dla ich widoki rozciągające się od sprawdzenia nazwą Super klas poprzez ViewConstructorDetector:
private static boolean isViewClass(ClassContext context, ClassNode node) {
String superName = node.superName;
while (superName != null) {
if (superName.equals("android/view/View") //$NON-NLS-1$
|| superName.equals("android/view/ViewGroup") //$NON-NLS-1$
|| superName.startsWith("android/widget/") //$NON-NLS-1$
&& !((superName.endsWith("Adapter") //$NON-NLS-1$
|| superName.endsWith("Controller") //$NON-NLS-1$
|| superName.endsWith("Service") //$NON-NLS-1$
|| superName.endsWith("Provider") //$NON-NLS-1$
|| superName.endsWith("Filter")))) { //$NON-NLS-1$
return true;
}
superName = context.getDriver().getSuperClass(superName);
}
return false;
}
O ile widzę moje nazwy klasy nie pasuje do wzorca wyżej. Czy ktoś ma pomysł, jak naprawić lub wyłączyć to ostrzeżenie?
getView() w BaseAdapter:
@Override
public final View getView(final int position, final View convertView, final ViewGroup parent) {
View view = convertView;
if (null == view) {
view = createNewView(parent, position);
} else {
reuseOldView(view, position);
}
return view;
}
Co implementuje twój adapter? Czy masz niestandardowy widok? – Neil
Nie, nic nie implementuję. Właśnie rozszerzam ArrayAdapter. – salcosand
w jakim celu? Adapter nie może działać samodzielnie. Do czego chcesz go użyć? – Neil