【发布时间】:2015-02-18 15:14:54
【问题描述】:
我从数据库中提取图像路径并创建一个 ImageView,然后将其添加到另一个包含所有图像的 ImageView。
LinearLayout linearContainer = (LinearLayout) findViewById(R.id.linearContainer);
ImageView imageViews = new LinearLayout(getApplicationContext());
linearContainer.addView(imageViews);
for all images
Bitmap myBitmap = ThumbnailUtils.extractThumbnail(
BitmapFactory.decodeFile(path), THUMBSIZE,
THUMBSIZE);
ImageView image = new ImageView(getApplicationContext());
image.setImageBitmap(myBitmap);
imageViews.addView(image);
image.setPadding(10, 10, 10, 10);
end
我为 ImageView 图像编写了一个点击监听器,它允许它编辑或删除。
imageViews.setOnClickListener() {
AlertDialog.Builder alert = new AlertDialog.Builder(FirstActivity.this);
// alert has two buttons: edit & delete
// Edit choice click listener
// Delete choice click listener
}
我需要知道路径才能从数据库中删除记录。但我没有得到关于添加“imageViews”实例的图像的任何信息。如何编写删除点击监听器?或者有没有其他更简单的方法来建立它?
【问题讨论】:
-
我只想在你的模型中有一个属性 imageId 以便每个图像都有它,然后根据该 id 删除它
标签: android imageview android-imageview android-image