Tell me how to make a handler for clicking on CardView, created programmatically. They are not arranged in a row, but are located in RelativeLayout under the desired elements. I load them with a loader
ArrayList<CardView> card = new ArrayList<CardView>(); int count; public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { count = 0; if (cursor.moveToFirst()) { do { //здесь считываю данные и расчитываю на какой высоте выставлять card.add((CardView)cv.findViewById(R.id.cardview)); card.get(count).getLayoutParams().height = здесь высота card.get(count).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //отсюда запускаю фрагмент с описанием этой cardview } }); ++count; } while (cursor.moveToNext()); } } as a result, going beyond (invalid index)
ListViewwith aSimpleCursorAdapterorRecyclerView. Believe me, this is 100 times more convenient than what you are doing now - Flippycountvariable moved out of the method? And you do not create cards programmatically, but pull out the same:cv.findViewById(R.id.cardview)- that is, the entire list will contain a bunch of links to one card. From here and "invalid index" - as it is impossible to add one twist to the container twice. - woesssonLoadFinishedyou refer to the same card, since you take it from the samecvcontainer. I think you need to fill out the list ofcardimmediately when creating them with a inflater. In general, show the error and more code of the code - from this piece it’s not very clear - woesss