在我的应用程序中,我必须使用搜索栏将调整大小应用于所选图像onclick,但问题是只有最后应用的贴纸视图可以调整大小,如果我想调整以前的贴纸视图,那么最后贴纸也会调整大小。 任何人都可以帮我解决这个问题
holder.icon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (a == 1) {
canvas.setBackgroundResource(mThumbIds[position]);
dialog.dismiss();
a = 0;
}
if (a1 == 1) {
Gallery gallery = (Gallery) findViewById(R.id.gallery);
gallery.setSpacing(1);
final GalleryImageAdapter galleryImageAdapter= new GalleryImageAdapter(getApplicationContext(),position);
gallery.setAdapter(galleryImageAdapter);
gallery.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
iv_sticker1 = new StickerImageView(MainActivity2.this);
if(x ==1)
iv_sticker1.setImageResource(galleryImageAdapter.mImageIds[position]);
if(x ==2)
iv_sticker1.setImageResource(galleryImageAdapter.mImageIds1[position]);
if(x ==3)
iv_sticker1.setImageResource(galleryImageAdapter.mImageIds2[position]);
canvas.addView(iv_sticker1);
}
});
a1 = 0;
}
if (a2 == 1) {
iv_sticker1 = new StickerImageView(MainActivity2.this);
iv_sticker1.setImageDrawable(getResources().getDrawable(mThumbIds2[position]));
canvas.addView(iv_sticker1);
iv_sticker1.setOwnerId(2);
dialog.dismiss();
a2 = 0;
}
if (a3 == 1) {
iv_sticker1 = new StickerImageView(MainActivity2.this);
iv_sticker1.setImageDrawable(getResources().getDrawable(mThumbIds3[position]));
canvas.addView(iv_sticker1);
dialog.dismiss();
a3 = 0;
}
}
});
这是我的调整大小程序
final SeekBar sk1 = (SeekBar) findViewById(R.id.seekBar1);
sk1.setMax(500);
sk1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// TODO Auto-generated method stub
iv_sticker1.getMainView();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(progress, progress);
iv_sticker1.setLayoutParams(params);
iv_sticker1.setMinimumWidth(progress);
iv_sticker1.setMinimumHeight(progress);
}
});
现在每当我这样做时,只有最后一次iv_sticker1被选中。如何在点击时将调整大小应用于所选图像?