그리드뷰를 구현해서
intent i = new Intent(gridviewgallery.this, photodetail.class);
i.putExtra("param1", position);
startActivity(i); 로 인텐트를 넘겼습니다.
그리고 받는 부분에서
Intetn intent = getIntent();
int position = intent.getExtras().getInt("param1");
Imageview view = (Imageview)findviewbyid(R.id.imageView1);
view.setImageResource(???????????);
이부분을 모르겠어요ㅠㅠ 안에 인자를 뭘로 넣어야할지 ㅠㅠ
public class MyAdapter extends BaseAdapter{
static List<Item> mItems = new ArrayList<Item>();
private LayoutInflater mInflater;
public MyAdapter(Context context){
mInflater = LayoutInflater.from(context);
mItems.add(new Item("2015졸업1", R.drawable.ccse));
mItems.add(new Item("2015졸업2", R.drawable.cse));
mItems.add(new Item("제목을길게하면어떻게될까궁금해서해봄", R.drawable.ic_launcher));
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mItems.size();
}
@Override
public Item getItem(int position) {
// TODO Auto-generated method stub
return mItems.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return mItems.get(position).drawableId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View v = convertView;
ImageView picture;
TextView name;
if (v == null) {
v = mInflater.inflate(R.layout.grid_item, parent, false);
v.setTag(R.id.picture, v.findViewById(R.id.picture));
v.setTag(R.id.text, v.findViewById(R.id.text));
}
picture = (ImageView) v.getTag(R.id.picture);
name = (TextView) v.getTag(R.id.text);
Item item = getItem(position);
picture.setImageResource(item.drawableId);
name.setText(item.name);
return v;
}
private static class Item {
public final String name;
public final int drawableId;
Item(String name, int drawableId) {
this.name = name;
this.drawableId = drawableId;
}
}
}
위는 어댑터 코드인데 배열이 List<>배열이라서 어떻게 받아와야 할지 모르겠네요
가로안에 List<gridviewgallery.MyAdapter.Item> mItems[position] 이런식으로 넣어봤는데도 안돼네요ㅠㅠ..
뭐가들어가는걸까요ㅠㅠ?