У меня есть пять строк imageView, но этот код загружает только 4 строки? Зачем?Загрузить изображения из файла tableLayout android
Java код
tl = (TableLayout) findViewById(R.id.tableLayout);
for (int i = 0; i < tl.getChildCount(); i++) {
View v = tl.getChildAt(i);
if (v instanceof TableRow) {
for (int j = 0; j < ((TableRow) v).getChildCount(); j++) {
View innerView = ((TableRow) v).getChildAt(j);
if (innerView instanceof ImageView) {
imageList.add((ImageView) innerView);
idList.add(innerView.getId());
}
}
}
}
Layout
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="false"
android:layout_alignParentBottom="true"
android:layout_marginBottom="275dp"
android:id="@+id/tableLayout">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView3"
android:layout_column="1"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView2"
android:layout_column="2"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_column="3"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView25"
android:layout_column="5"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView5"
android:layout_column="6"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView13"
android:layout_column="1"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView12"
android:layout_column="2"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView11"
android:layout_column="3"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView10"
android:layout_column="5"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView14"
android:layout_column="6"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView9"
android:layout_column="1"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView8"
android:layout_column="2"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView6"
android:layout_column="3"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView7"
android:layout_column="5"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView4"
android:layout_column="6"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView18"
android:layout_column="1"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView17"
android:layout_column="2"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView16"
android:layout_column="3"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView15"
android:layout_column="5"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView19"
android:layout_column="6"
android:nestedScrollingEnabled="false"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView23"
android:layout_column="1"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView22"
android:layout_column="2"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView21"
android:layout_column="3"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView20"
android:layout_column="5"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView24"
android:layout_column="6"
android:src="@drawable/blog_dp_5058985_7848593_tr_woda" />
</TableRow>
</TableLayout>
пожалуйста, напишите XML или код, который создает TableLayout – csenga
http://pastebin.com/3q5iRURi, потому что я не могу добавить код здесь. – Pekus
Я проверил ваш код, он отлично работает, все 25 ImageViews были добавлены в imageList. – csenga