private void fillList() { ListView list = (ListView) findViewById(R.id.other_items_list); int itemsCount = mDbAdapter.getContentItemCountByCategory(mCategoryId); Random rand = new Random(); for (int i = 0; i < sListItemsCount; i++) { int index = rand.nextInt(itemsCount); while ((index == mIndex) || member(mItemsId, index, i)) { index = rand.nextInt(itemsCount); } mItemsId[i] = index; } SecondListAdapter adapter = new SecondListAdapter(this, mDbAdapter, mItemsId, mCategoryId); list.setAdapter(adapter); list.setOnItemClickListener(this); }