Android 加载图片
我想在屏幕上一次只加载4个图片,依次排列。
我有100个图片,需要分次加载。
点击button "下一页"后,要显示后续的图片。
setImageDrawable(getResources().getDrawable(R.drawable.t4 + 1));//出错
有什么方法吗?
谢谢
下面是layout的配置:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f0f8ff"
>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/group_companies"
>
<TableRow>
<ImageButton
android:id="@+id/company1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/t1"
android:background="#f0f8ff"
android:layout_weight="1"
android:layout_marginLeft="0dp"
/>
</TableRow>
<TableRow>
<ImageButton
android:id="@+id/company2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/t2"
android:background="#f0f8ff"
android:layout_weight="1"
android:layout_marginLeft="0dp"
/>
</TableRow>
<TableRow>
<ImageButton
android:id="@+id/company3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/t3"
android:background="#f0f8ff"
android:layout_weight="1"
android:layout_marginLeft="0dp"
/>
</TableRow>
<TableRow>
<ImageButton
android:id="@+id/company4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/t4"
android:background="#f0f8ff"
android:layout_weight="1"
android:layout_marginLeft="0dp"
/>
</TableRow>
<Button android:id="@+id/next"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="100"
android:text="下一页" />
</TableLayout>
</RelativeLayout>