I created more than one "PhotoView" and variables I wanted to use with the following code:
public void SayfaEkle(int id) throws JSONException {
LayoutInflater inflater = this.getLayoutInflater();
FrameLayout f;
int photos = 0;
switch (id){
case 1:
photos = 5;
final Drawable bitmap = ContextCompat.getDrawable(this,R.drawable.complex);
f = (FrameLayout) inflater.inflate (R.layout.foto_layout_1, null);
int pageId = addView(f);
sayfa_sablon_ids.put("Sayfa_"+pageId, id);
Map<String, PhotoView> fotograflar = new HashMap<String, PhotoView>();
for( int z = 1; z<= photos; z++ ) {
int idResource = getResources().getIdentifier("photo_" + z + "_area", "id", getPackageName());
final PhotoView photoview = (PhotoView) f.findViewById(idResource);
photoview.setScaleType(ImageView.ScaleType.CENTER_CROP);
photoview.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
photoview.setImageDrawable(bitmap);
Log.d("OnClick"," yes ");
}
});
fotograflar.put("pView"+z,photoview);
}
sayfalar.put("Sayfa_"+pageId,fotograflar);
break;
case 2:
f = (FrameLayout) inflater.inflate (R.layout.foto_layout_2, null);
Log.d("id", "IKI --------------------");
break;
default:
f = (FrameLayout) inflater.inflate (R.layout.foto_layout_1, null);
}
}
But in this code I choose the photo. I want this photo to be selected by the user by clicking on "PhotoView".
How can I do it?