我创建了多个“PhotoView”和我想与以下代码一起使用的变量:
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);
}
}
但在这段代码中,我选择了照片。我希望用户通过单击“PhotoView”来选择这张照片。
我该怎么做?