Anzeigen für ListView-Element / umgekehrte Reihenfolge auf 2.2 erhalten; arbeitet an 4.0.3
Ich habe eine ListView, die Elemente aus ArrayAdapter zeigt. Ich möchte die Ansicht animieren, wenn auf sie geklickt wird. Das Problem ist, dass ich auf verschiedenen Android-Versionen unterschiedliche Ansichten bekomme (siehe unten)
Ich erhalte die Ansicht von ListActivity mit dieser Methode:
private View getViewForListPosition(int position) {
int firstPosition = mList.getFirstVisiblePosition() - mList.getHeaderViewsCount();
int wantedChild = position - firstPosition;
ZLog.d(LOG,"getViewForListPosition , position : " + position + ", wantedChild : " + wantedChild + ", view hash : " +mList.getChildAt(wantedChild).hashCode());
for(int i = mList.getChildCount(); i>0; i--){
ZLog.d(LOG, "pos : " + (i-1) + ", hash : " +mList.getChildAt(i-1).hashCode());
}
return mList.getChildAt(wantedChild);
}
Damit bekomme ich auf Android 4.0.3 & 4.2.2 Handys:
getViewForListPosition , position : 3, wantedChild : 3, view hash : 1101734248
pos : 5, hash : 1104109360
pos : 4, hash : 1104254936
pos : 3, hash : 1101734248
pos : 2, hash : 1104876880
pos : 1, hash : 1104862296
pos : 0, hash : 1104793008
dann, wenn Artikel geklickt wird, mein AdaptergetView
Methode läuft für jede Ansicht:
getView, position : 0, convertView is notnull, cv hash1104793008
getView, position : 1, convertView is notnull, cv hash1104862296
getView, position : 2, convertView is notnull, cv hash1104876880
getView, position : 3, convertView is notnull, cv hash1101734248
getView, position : 4, convertView is notnull, cv hash1104254936
getView, position : 5, convertView is notnull, cv hash1104109360
Sie können also sehen, dass alles in Ordnung ist und wie erwartet funktioniert. Wenn ich dies jedoch auf Android 2.2 ausführe, erhalte ich die folgenden Ergebnisse:
getViewForListPosition , position : 3, wantedChild : 3, view hash : 1205607672
pos : 5, hash : 1205730120
pos : 4, hash : 1205712904
pos : 3, hash : 1205607672
pos : 2, hash : 1206547728
pos : 1, hash : 1206483960
pos : 0, hash : 1207864856
getView, position : 0, convertView is notnull, cv hash1205730120
getView, position : 1, convertView is notnull, cv hash1205712904
getView, position : 2, convertView is notnull, cv hash1205607672
getView, position : 3, convertView is notnull, cv hash1206547728
getView, position : 4, convertView is notnull, cv hash1206483960
getView, position : 5, convertView is notnull, cv hash1207864856
so wie du vielleicht bemerkt hastgetViewForListPosition
Ich gebe die Ansicht zurück, die der Adapter für Position 2 verwendet
Vielleicht haben Sie auch bemerkt, dass entweder dieAdapter.getView
oderListView.getChildAt
sendet Artikel in umgekehrter Reihenfolge zurück, wodurch dieses Problem verursacht wird. Was könnte der Grund für dieses Verhalten sein? (Ich mache nichts Besonderes in meinem Adapter)
Für jeden Hinweis bin ich dankbar. Vielen Dank!