안드로이드 개발 질문/답변
(글 수 45,052)
하지만 세로로 1개씩만 나오네요,
어느 부분이 잘못된걸까요 ㅠ_ㅠ;;
class ImageAdapter extends BaseAdapter {
private Context mContext;
//테스트용으로 같은 이미지만 배열에 3개 가져왔습니다.
int[] picture = { R.drawable.back_frame, R.drawable.back_frame, R.drawable.back_frame};
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return 10;
}
public Object getItem(int position) {
return picture[position % 3];
}
public long getItemId(int position) {
return position;
}
public View getView (int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setAdjustViewBounds(false);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(picture[position % 3]);
return imageView;
}
2011.07.14 16:42:01
adapter안에서 구현하는게 오류입니다 여기서는 그리드뷰 중 하나의 아이템의 데이터를 셋팅해줄 뿐이죠 그리드뷰를 선언한 액티비티나 xml의 속성으로해결하셔야합니다
2011.07.14 18:08:06
에고, 제가 별로 필요없을것 같고, 일부러 보시기 편하라고 저것만 올린건데..ㅠㅠ
public class PFrameFrame extends Activity { public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.layout_frame);
GridView grid = (GridView)findViewById(R.id.layout_frame);
ImageAdapter Adapter = new ImageAdapter(this);
grid.setAdapter(Adapter);
}
}



