画像を画面に2カラムで表示したいです。
以下の流れで作ろうと思っているんですが、②の画像の取得方法がいまいちわかりません。恐らくは配列で画像を取得してそれをアダプタにセットする流れだと思うんですが、アドバイスをいただきたいです。
lang
1//①xml内のグリッドを取得 2GridView mGrid = (GridView) findViewById(R.id.myGrid); 3//②画像を取得 4 5//③アダプタを作成 6 ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(this,R.layout.myGrid,mThumbIds); 7//④Adapterをセット 8mGrid.setAdapter(myAdapter);
lang
1<?xml version="1.0" encoding="utf-8"?> 2<GridView xmlns:android="http://schemas.android.com/apk/res/android" 3 android:id="@+id/myGrid" 4 android:layout_width="fill_parent" 5 android:layout_height="fill_parent" 6 android:padding="10dp" 7 android:verticalSpacing="10dp" 8 android:horizontalSpacing="10dp" 9 android:numColumns="auto_fit" 10 android:columnWidth="60dp" 11 android:stretchMode="columnWidth" 12 android:gravity="center" />
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。