getView メソッド内で、特定の子ビューを取得したいと考えています。getCount を呼び出すことで、アダプターが複数のアイテムを保持していることがわかります。
getCount();
JavaDocによると:
public abstract int getCount ()
Added in API level 1
How many items are in the data set represented by this Adapter.
今私のgetViewメソッドで:
public View getView(final int position, View convertView, ViewGroup parent) {
View lastAddedItem = parent.getChildAt(getCount()-1);
if(lastAddedItem == null) {
Log.w("ListAdapter", "View is null");
}
}
このメッセージは常に に表示されますLogCat
。これは、取得しようとしているビューが であることを意味しますNull
。
私もこれを試しました:
View lastAddedItem = parent.getChildAt(parent.getChildCount()-1);
ViewGroup
では、オブジェクトから特定のビューを取得するにはどうすればよいでしょうか?