setAdapter 는 한꺼번에 이미지를 gallery 에 올리는데
갤러리에 이미지 넣을수 있는 액자 12개 미리 만들어 주고
그후 스래드를 이용하여 하나씩 올라가는 과정을 보여주고 싶습니다
예로들면
이런식으로 이미지가 있는데
ㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁ
↓
■ㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁ
↓
■■ㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁㅁ
.......
.....
■■■■■■■■■■■■■■■■■■
여러 방법을 해보았는데 인터넷에서도 잘 안나오고 ......
한꺼번에 말고
gallery 에
원하는 위치에 이미지를 하나씩 넣을수 있는 제공된 함수가 있나요?
이렇게 말입니다 소스는 이렇습니다
public class GALTEST extends Activity {
private String url_ImageUrl = "http://www.xxxxx.com/xxxxx/xxxx/";
private String[][] url_newItems;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageURL ur = new ImageURL();
url_newItems = ur.get_NewItems();
ImageAdapter adep_Image= new ImageAdapter(this);
Gallery gly_newItems = (Gallery)findViewById(R.id.g_newItems);
gly_newItems.setAdapter(adep_Image);
gly_newItems.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
});
}
/******************** CLASS ********************/
public class ImageAdapter extends BaseAdapter
{
private int mGalleryItemBackground;
private Context mContext;
private Bitmap[] bit_Items = new Bitmap[12];
public ImageAdapter(Context c)
{
mContext = c;
TypedArray a = c.obtainStyledAttributes(R.styleable.GalleryTheme);
mGalleryItemBackground = a.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
a.recycle();
}
public int getCount() { return 12; }
public Object getItem(int position) { return position; }
public long getItemId(int position) { return position; }
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
ImageView i = new ImageView(mContext);
//
i.setLayoutParams(new Gallery.LayoutParams(200, 150));
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setBackgroundResource(mGalleryItemBackground); ;
downloadFile(url_ImageUrl + url_newItems[position][0], position, bit_Items);
i.setImageBitmap(bit_Items[position]);
return i;
}
public void downloadFile(String fileUrl, int i, Bitmap[] bitmap_Items)
{
URL myFileUrl = null; // URL 타입의 myFileUrl을 NULL로 초기화 시켜줍니다.
try
{
myFileUrl = new URL("fileUrl); // 파라미터로 넘어온 Url을 myFileUrl에 대입합니다.
}
catch(MalformedURLException e) // 예외처리를 해줍니다.
{
// Todo Auto-generated catch block
e.printStackTrace();
}
try
{
HttpURLConnection conn = (HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
//int length = conn.getContentLength(); // 받아온 컨텐츠의 길이를 length 변수에 저장합니다.
InputStream is = conn.getInputStream(); // InputStream is 변수에 받아온 InputStream을 저장합니다.
bitmap_Items[i] = BitmapFactory.decodeStream(is); // 받아온 이미지를 bmImg에 넣어둡니다.
conn.disconnect();
}
catch(IOException e)
{
}
}
}
}




http://www.androidpub.com/index.php?mid=android_dev_info&page=1&document_srl=1677594