我有包含 5000 个项目的列表视图。我想在某个位置获取列表视图项并对其进行处理,我调用 getListView().getChildAt(1) 方法并返回 null。
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_items);
cur = ItemDao.getItemsCursor();
column_names = new String[] { ItemDao.NAME, ItemDao.MEASUREUNIT, ItemDao.REM };
columns = new int[] { R.id.item_name, R.id.item_measureunit, R.id.item_rem };
scadap = new SimpleCursorAdapter(this, R.layout.list_items, cur, column_names, columns, 0);
ListView list = getListView();
list.setDivider(getResources().getDrawable(android.R.drawable.divider_horizontal_bright));
list.setDividerHeight(10);
setListAdapter(scadap);
list.invalidateViews();
(getListView().getChildAt(getListView().getFirstVisiblePosition())).setVisibility(View.INVISIBLE);
}