我撰写了来自ArrayAdapter的习俗接触书。 让我们假设,名单仅有三个要素。 我在每打听电文的电话中都收发了字眼和信条。 我注意到,观点反对没有正确归还。 我在这里做了一些错误的事情?
private class ContactListAdapter extends ArrayAdapter<ContactItem> {
... ...
@Override
public View getView(int aPosition, View aConvertView, ViewGroup aParent) {
Log.d(TAG, "Inside ContactListAdapter.getView()");
if(aConvertView==null) {
Log.d(TAG, "ConvertView is null");
// Inflate view...
}
Log.d(TAG, "Pos: " + aPosition + " View: " + aConvertView.hashCode());
return aConvertView;
}
这里是初步意见生成的标志:
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): ConvertView is null
D/ContactsActivity( 759): Pos: 0 View: 1156974184
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): ConvertView is null
D/ContactsActivity( 759): Pos: 1 View: 1157007416
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): ConvertView is null
D/ContactsActivity( 759): Pos: 2 View: 1157027832
当我点击名单上的第三点时,就会出现记录(不知道如何交换第一和最后元素的散射编码)。 我的Click方法仅仅使名单上的少数实体:
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): Pos: 0 View: 1157027832
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): Pos: 1 View: 1157007416
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): Pos: 2 View: 1156974184
当我点击第二个要素时,标识:
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): Pos: 0 View: 1156974184
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): Pos: 1 View: 1157007416
D/ContactsActivity( 759): Inside ContactListAdapter.getView()
D/ContactsActivity( 759): Pos: 2 View: 1157027832
这一点一再得到观察,每次只交换头和最后入境的散射编码。 这可能是什么原因?