반응형
Sample Code
<Layout>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:spacing="5px"
android:animationDuration="1500"/>
<Java>
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(new ImageAdapter2(this));
class ImageAdapter2 extends BaseAdapter{
private Context con;
private int[] imageIds = { ~, ~, ~, ~, ~};
public ImageAdapter2(Context c){con = c; }
public int getCount(){ return mImageIds.length; }
public Object getItem(int position){ return imageId[position]; }
public long getItemId(int position) { return position; }
public View getView(int position, View convertView, ViewGroup parent){
ImageView imageView;
if (convertView == null){
imageView = new ImageView(con);
}
else{
imageView = (ImageView)convertView;
}
imageView.setImageResources(imageId[position]);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(new Gallery.LayoutParams(136, 88));
return imageView;
}
}
로그인 없이 추천 가능합니다. 손가락 꾸욱~
반응형
'프로그래밍 놀이터 > 안드로이드, Java' 카테고리의 다른 글
[Android/안드로이드] Rainbow progress bar ( custom view sample code ) (0) | 2012.02.28 |
---|---|
[Android/안드로이드] Custom View ( 커스텀 뷰 ) 만드는 방법. (0) | 2012.02.28 |
[Android/안드로이드] GridView ( 그리드 뷰 ) with sample code. (0) | 2012.02.28 |
[Android/안드로이드] Spinner ( 스피너 ) 에 대해 알아봅니다. ( with sample code ) (0) | 2012.02.28 |
[Android/안드로이드] Editable 은 무엇인가? (0) | 2012.02.28 |
댓글