嗨,我需要在GridView
中放一个按钮,以便从“图库”中选择“图像”。一旦我选择了一张图像,此按钮将滑动到所选ImageView
的下一个位置,依此类推,依此类推。 Pluse Icon will be there to select image
我在这里做什么
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.demo);
gv_image = (GridView) findViewById(R.id.gv_image);
actualGridItem = new ActualGridItem();
GridAdapter adapter = new GridAdapter(this, new GridItem() {
@Override
public String getImgUrl() {
// TODO Auto-generated method stub
return "+ image url";
}
@Override
public long getId() {
// TODO Auto-generated method stub
return -1;
}
});
adapter.addItem(actualGridItem);
gv_image.setAdapter(adapter);
}
我的适配器
public class GridAdapter extends BaseAdapter {
private List<GridItem> items;
private Context context;
GridAdapter(Context context, GridItem addImageItem) {
this.items = new ArrayList<GridItem>();
this.context = context;
this.items.add(addImageItem); // at this moment we only have + item
}
public void addItem(GridItem actualItem) {
int insertLocation = this.items.size() - 2; // Before last item, last always will be +
this.items.add(insertLocation, actualItem);
notifyDataSetChanged();
}
@Override
public int getCount() {
return this.items.size();
}
@Override
public GridItem getItem(int position) {
return this.items.get(position);
}
@Override
public long getItemId(int position) {
return this.items.get(position).getId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = new ImageView(context);
// Customize image view
}
GridItem currentItem = items.get(position);
// load image with url currentItem.getImgUrl();
return convertView;
}
}
请帮助我实现这一目标。