¾È³çÇϼ¼¿ä Áö³¹ø¿¡ Áú¹®±Û ¿Ã·È´ø ÀÎÅÏÀÔ´Ï´Ù.ÁÖ¸»¿¡ ½¬°í¿À´Ï±î ¸Ó¸®°¡ Á» »óÄèÇØÀú¼ ±×·±Áö Àú¹øÁÖº¸´Ù ¼Ò½º¸¦ Á¶±Ý ħÂøÇÏ°Ô Çؼ®ÇÏ°Ô됬³×¿ä. Àü¿£ ¾Æ¿¹¾Èº¸¿´´Âµ¥...
Áö³¹ø¿¡ ´äº¯ÁֽŠȣ±º´Ô °¨»çÇÕ´Ï´Ù.
±æ°Ô ´äº¯ÇÏ´Â°Ô ±ÍÂúÀ¸½Ã¸é ÁÖ¼®´Ü°Å Àо½Ã°í µû·Î ¼³¸í ¾ÈÇϽðí o,x¸¸À¸·Î¶óµµ ¾Ë·ÁÁֽøé Á¤¸» °¨»çÇÏ°Ú½À´Ï´Ù...¹¹¶óÇصµ Ʋ¸° Á¤º¸¸¦ ¸Â´Ù°í »ý°¢ÇÏ°íÀÖÀ¸¸é ÈÄ¿¡ Å« ¹®Á¦°¡ µÇ´Ï±î¿ä...¤Ð¤Ð
private Context mContext; :namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
public ImageAdapter(Context c) {
mContext = c;
}
//context¸¦ mcontext¶ó´Â À̸§À¸·Î ¼±¾ðÇØÁØ´ÙÀ½¿¡ ImageAdapter¿¡¼»ç¿ëÇÑ´Ù°í ÇÕ´Ï´Ù.c¶ó´Â º¯¼ö´Â context±â´ÉÀ» °®´Â´Ù°í ¼±¾ðÇÏ°í mContext¶ó´Â º¯¼ö¿¡ c(context)¸¦ ³Ö½À´Ï´Ù.
ÀÌ·¸°ÔÇÏ´Â ÀÌÀ¯´Â ImageAdapter´Â Context¸¦ ÇÊ¿ä·ÎÇÏ´Â ±â´ÉÀ̱⶧¹®ÀÔ´Ï´Ù.
±Ã±ÝÇÑÁ¡Àº ±×³É Context°¡ ÇÊ¿äÇϸé context¶ó°í ½á¼ ±â´ÉÀ» »ç¿ëÇÏ¸é ¾ÈµÇ°í ÀÌ·¸°Ô º¹ÀâÇÏ°Ô ´Ù¸¥º¯¼ö¿¡ Áý¾î³Ö¾î¼ »ç¿ëÇؾ߸¸ Çϴ°¡ÀÔ´Ï´Ù.
public int getCount() {
return mThumbIds.length;
}
//intÇü getCount¶ó´ÂÀ̸§À¸·Î ÇÔ¼ö¸¦ »ý¼ºÇÏ°í mThumbIds¶ó´Â À̸§ÀÇ º¯¼öÀÇ ±æÀÌ°ªÀ» Àü´ÞÇØÁÝ´Ï´Ù.±×¸®°í getcount¸¦ Æ÷ÇÔÇÑ ¾Æ·¡ÀÇ ÇÔ¼ö4°³´Â baseAdapter class»ç¿ëÇÒ¶§ ¹Ýµå½Ã Æ÷ÇԵǾî¾ß ÇÏ´Â ³»¿ëÀÇ ÇÔ¼öµéÀ̶ó°í Çϳ׿ä.
public Object getItem(int position) {
return null;
}
// getItem À̶ó´Â À̸§ÀÇ ÇÔ¼ö¸¦ »ý¼±ÇÏ¸é¼ intÇü positionÀ̶ó´Â º¯¼ö¸¦ »ý¼ºÇÕ´Ï´Ù.ÀÌ ÇÔ¼ö´Â NUll°ªÀ» º¸³»ÁÝ´Ï´Ù. ÀÌ Object¶ó´Â Çü½ÄÀº Ŭ·¡½ºµéÀÇ °¡Àå ÃÖ»óÀ§ Ŭ·¡½º·Î Çü½Ä ÁöÁ¤°°Àº°Ô ¾Ö¸ÅÇÒ¶§ ½áµµµÈ´Ù°í ...Áö½ÄÀÎ Çü´ÔÀº ¸»¾¸ÇϽó׿ä..;
Á» Àç¹Õ´Ù°í »ý°¢ÇÑ°Ô Áö±Ý±îÁø º¯¼ö¼±¾ðÀ̳ª ÇÔ¼öÀÇ Çü½Ä ¼±¾ðÀº int char ÀÌ·±°Å¸¸ ½á¿Ô´Âµ¥(c¾ð¾î) Àú·±½ÄÀ¸·Î ÀÌ¹Ì ¸¸µé¾îÁ®ÀÖ´Â ÇÔ¼öÀÎÁö Ŭ·¡½ºÀÎÁö ¾Æ¹«Æ° Àú·±°Íµµ Çü½ÄÀ¸·Î ÁöÁ¤ÇØ ÁÙ ¼öÀÖ´Â °Í °°´õ±º¿ä..Á¦°¡ »ý°¢ÇÏ°íÀÖ´Â°Ô ¸Â³ª¿ä?
public long getItemId(int position) {
return 0;
}
//À§¿Í °°½À´Ï´Ù. ´Ù¸¸ getItemId´Â 0À» ¸®ÅÏÇÕ¤¾´Ï´Ù. ¹æ±ÝÈ®ÀÎÇѰǵ¥
getItem.getView.getCount.getItemId 4°³ÇÔ¼ö´Â ÇÔ¼ö À̸§¸¸ ¹Ù²ãµµ ¹Ù·Î ¿¡·¯°¡³ª´õ±º¿ä. ÇÔ¼öÀ̸§Àº ±×´ë·ÎµÎ°í getitemÇÏ°í itemidÀÇ Çü½Ä°ú ¸®Åͳ»¿ë¸¸ ±×´ë·Î¹Ù²ãÄ¡±â Çߴµ¥µµ ¿¡·¯³ª°í baseApdater¾µ¶§ Çʼö·Î µé¾î°¡´Â ÇÔ¼ö¶ó´Â ¸»ÀÌ ±× ¸»ÀÎ °Í °°³×¿ä. ÀÌ ÇÔ¼ö4°³´Â baseAdatper¾µ¶§ ¹Ýµå½Ã À̳»¿ë ±×´ë·Î µé¾î°¡¾ßÇѴٴ°Š¸Â³ª¿ä(mThumbº¯¼öÀ̸§À̶û. ImageView À̸§¸¸ »©°í ´Ù ±×´ë·Î)
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
//View ±â´ÉÀ» °®°íÀÖ´Â getView¶ó´Â ÇÔ¼ö¸¦ »ý»êÇÕ´Ï´Ù.(¾Æ¸¶ View¶ó´Â Ŭ·¡½º?ÇÔ¼ö?´Â gridview±â´ÉÀ» Æ÷ÇÔÇÏ°íÀÖ´Â ÀÌ ±×¸®µåºä¾î ÇÁ·Î±×·¥¿¡¼± ÇʼöÀûÀÎ ±â´ÉÀÌ°ÚÁÒ) ±×¸®°í ÀÎƼÀú Çü½ÄÀ¸·Î Æ÷Áö¼Ç, View Çü½ÄÀ¸·Î convertView, ViewGrouÇü½ÄÀ¸·Î parent¶ó´Â º¯¼ö¸¦ ¼±¾ðÇØÁÝ´Ï´Ù.) ¸¶Áö¸·À¸·Î ImageView´Â imageView¶ó´Â À̸§À» °®´Â´Ù°í ¼±¾ðÇØÁÝ´Ï´Ù.
if (convertView == null) {
// if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8); }
//ImageView¸¦ »õ·Î »ý¼±ÇÏ°í ImageView´Â contextÀÇ ±â´ÉÀ» °®°íÀÖ½À´Ï´Ù.(Çʼö ¹®ÀåÀ̶ó°í »ý°¢µË´Ï´Ù. ¿©±â¼ ±Ã±ÝÇÑ°Ç ¸ÇÀ§¿¡ Áú¹®¿¡¼ Àû¾ú´Âµ¥ ÀÌ°É ¿Ö ±ÍÂú°Ô mContext¶ó°í ½á¾ßÇÏ´ÂÁö ÀÔ´Ï´Ù. ±×³É Context¶ó°í ¾²¸é ¾ÈµÇ´Â ÀÌÀ¯°¡...) ³ª¸ÓÁö´Â »çÀÌÁî °ü·ÃÀÔ´Ï´Ù.
else {
imageView = (ImageView) convertView;
}
//À̹ÌÁö°¡ ÀÖÀ»°æ¿ì¶ó´Âµ¥. À̺κи¸ Á¶±Ý ¼³¸í ÇØÁÖ½Ã¸é °¨»çÇÏ°Ú½À´Ï´Ù...
À̹ÌÁö°¡ ÀÖÀ»°æ¿ì imageView ¿¡ convertView´Ï±î ¾Æ¸¶ View¿¡ ³²¾ÆÀÖ´Â À̹ÌÁö°ÚÁÒ ¸¦ ³Ö´Â´Ù´Â°Çµ¥ ¾Õ¿¡(ImageView)ÀÇ Àǹ̸¦ ¸ð¸£°Ú³×¿ä
imageView.setImageResource(mThumbIds[position]);
return imageView; }
//imageView¿¡ ImageResource¸¦ ¼ÂÆÃÇÏ°í ±× ResourceÀÇ ¾È¿¡´Â mThumBIds¹è¿ÀÇ À̹ÌÁöµéÀ» ¼ø¼´ë·Î ³Ö´Â´Ù) ±×¸®°í imageView °ªÀ» ¸®ÅÏÇÑ´Ù. (set.ImageResource ¶ó´Â ºÎºÐµµ ÇʼöÀûÀÎ ºÎºÐÀÎ °Í °°Àºµ¥ ±â¾ïÇص־߰ÚÁÒ?)
// references to our images
private Integer[] mThumbIds = { R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7
};
}
// Integer¶ó´Â°Ô int ÀÇ ¾î¼°í Àú¼´Â ±â´ÉÀ» Æ÷ÇÔÇؼ °°ÀÌ ³Ö¾îµÐ Ŭ·¡½ºÀ̸§ÀÌ´õ±º¿ä. ±×·¡¼±×³É int·Î ½áºÃ´Âµ¥ ¶È°°ÀÌ µÇ´õ¶ó±¸¿ä. ±»ÀÌ ±Ã±ÝÇÑ°Ç ¿Ö int¸¦ ¾È¾²°í Integer¸¦ 썻³ª ÇÏ´ÂÁ¡ Á¤µµ±¸¿ä....ÀÌÇØ°¡ ¾È°¡´Â°Å µÎ°¡Áö´Â
¾î¶ó..int´Â Á¤¼öÇüÀε¥ ¾î¶»°Ô ¹è¿¾È¿¡ Á¤¼ö "°ª"ÀÌ ¾Æ´Ï¶ó. ±×¸²ÀÌ ÀúÀåµÈ ÁÖ¼Ò°¡ µé¾î°¥ ¼ö ÀÖÁö?? Àú°Ô °¡´ÉÇÑ°¡...?¶ó´Â »ý°¢ÀÌ µé¾ú³×¿ä...°¡´ÉÇÏ´Ï±î µÈ°Å°ÚÁö¸¸..Àú°Ô°¡´ÉÇØ¿ä??;;
Çϳª ´õ ±Ã±ÝÇÑ°Ç. º¸½Ã¸é »çÁøÀÌ ÃÑ 8ÀåÀÔ´Ï´Ù. ¶È°°Àº»çÁøÀÌ ¿©·¯¹ø Ãâ·ÂµÇÁÒ...Àý´ë ¹«Á¶°Ç ´ç¿¬È÷ µÈ´Ù°í »ý°¢Çؼ ¾ÈÇÏ°íÀÖ¾ú´Âµ¥ °¾ÆÁö ±×¸²ÀÌ Áú·Á¼ À©µµ¿ì¿¡ ÀÖ´Â »çÁø 14Àå ´õ »©¿Í¼ sample_21±îÁö ¸¸µé¾ú½À´Ï´Ù...±Ùµ¥ ¿ô±ä°Ç Àú ¹è¿ÁÖ¼Ò¿¡ 0ºÎÅÍ 21±îÁö ´Ù ½á³Ö¾ú´Âµ¥ ¿¡·¯°¡ ³ª´Â°Å¿¡¿ä...sample_12±îÁö´Â ¿¡·¯°¡¾È³³´Ï´Ù...»çÁøÀÌ ¹®Á¦Àΰ¡Çؼ 13¹ø »ùÇÃÀ» 12¹øÀ¸·Î ¹Ù²ãºÃ´Âµ¥ ¿¡·¯°¡ ¾È³ª´õ±º¿ä...»çÁø¹®Á¦µµ ¾Æ´Ï°í sample_13¹ø ÀÌ»óÀ¸·Î ÀúÀåµÈ À̸§ÀÌ Çϳª¶óµµ µé¾î°¡¸é ¿¡·¯°¡³ª³×¿ä...À̰Ǿƹ«¸®ºÁµµ Àý´ë ÀÖÀ»¼ö°¡ ¾ø´ÂÀÏÀε¥...ÀüÇô ÀÌÇØ°¡¾È°¡¿ä.
¾Æ..Á˼ÛÇÕ´Ï´Ù ÇÑ°¡Áö¸¸´õ ¤Ð
¹è¿ °¹¼ö [] ¾È¿¡, ÇöÀç »çÁøÀÇ °¹¼ö°¡ ÃÑ 22°³¶ó¼ 22¸¦ 썻´Âµ¥..¿Ö Àú ´ë°ýÈ£ ¾È¿¡ ¼ýÀÚ¸¸ Àû¾î³ÖÀ¸¸é mThumbº¯¼ö¿¡ »¡°£ÁÙÀÌ »ý±æ±î¿ä...
°³¹ßÀÚ ÇÁ·Î±×·¡¸Ó Çü´Ô ´©³ª µ¿»ý »ïÃ̺еé Á¤¸» °£ÀýÈ÷ ´äº¯À» ¿øÇÕ´Ï´Ù. µµ¿ÍÁÖ¼¼¿ä Çø®Áî
Çѱ¹°¡¸é ¹ä»çµå¸±°Ô¿ä Á¦¹ß ¤Ð.¤Ð