<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/product_gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:scrollbars="vertical"
android:stretchMode="columnWidth"
/>
</LinearLayout>
그리드뷰 xml이구요
private List<String> sdcardpath;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO Auto-generated method stub
setContentView(R.layout.activity_album);
GridView gv_album = (GridView)findViewById(R.id.product_gridview);
gv_album.setAdapter(new ImageGridAdapter(this));
}
액티비티입니다
public class ImageGridAdapter extends BaseAdapter{
private Context context = null;
private List<String> sdcardpath;
public ImageGridAdapter(Context con){
this.context = con;
try{
sdcardpath = new ArrayList<String>();
File[] file = new File(Environment.getExternalStorageDirectory()+"/newtalktalk/").listFiles();
for(File filename : file){
sdcardpath.add(Environment.getExternalStorageDirectory()+"/newtalktalk/" + filename.getName().toString());
}
}catch (Exception e) {
// TODO: handle exception
Log.d("ErrorLog", "ImageAdapter : " + e.toString() );
}
}
// 이미지의 갯수
@Override
public int getCount() {
// TODO Auto-generated method stub
return sdcardpath.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position ;
}
// 선택된 이미지ID를 반환
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View v = convertView;
v = View.inflate(context, R.layout.testgridview, null);
ImageView v_image = (ImageView)v.findViewById(R.id.photoimage);
try{
if(null != convertView){
//v_image = (ImageView)convertView;
Bitmap bmp = BitmapFactory.decodeFile(sdcardpath.get(position).toString());
bmp = Bitmap.createScaledBitmap(bmp, 320, 240, false);
v_image.setImageBitmap(bmp);
}else{
//이미지 사이즈 조정 320 * 240
Bitmap bmp = BitmapFactory.decodeFile(sdcardpath.get(position).toString());
bmp = Bitmap.createScaledBitmap(bmp, 320, 240, false);
// 이미지뷰 재정의
//v_image = new ImageView(context);
v_image.setAdjustViewBounds(true);
v_image.setImageBitmap(bmp);
//ImageViewOnClickListener imageviewclick = new ImageViewOnClickListener(context, Imageids[position]);
//v_image.setOnClickListener(imageviewclick);
}
}catch (Exception e) {
// TODO: handle exception
Log.d("ErrorLog", "ImageAdapter GetView : " + e.toString());
}
return v;
}
그리드뷰 아답터인데요..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/photoimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<CheckBox
android:id="@+id/chk_selectphoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
커스텀레이아웃입니다..
layout은 잘나옵니다.. 체크박스 체크도 되구요..
근데.. =ㅅ= 이거 체크박스 체크를 해놓구.. 스크롤하게되면.. 체크박스 체크 해놧던게;
초기화 됩니다 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
럴수.......... 도와주세요 고수님들..ㅜ.ㅜ
어느부분이 잘못됫을까여??
아니면 그리드뷰 속성이 잘못된건가요?ㅜㅜ