ivAttachment1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(strPhoto1 == "" && PageType.equals("NewRequestMedical")) {
Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);
photoTemp = "photo1";
}
else if(strPhoto1 == "" && !PageType.equals("NewRequestMedical"))
{
Toast.makeText(getApplicationContext(), "there is no attachment on this request",
Toast.LENGTH_SHORT).show();
}else {
Intent i = new Intent(MedicalClaim.this, DetailPhotoMedical.class);
/* i.putExtra("photo", strPhoto1);*/
Bundle extras = new Bundle();
extras.putString("photo", strPhoto1);
extras.putString("photoNo","photo1");
extras.putString("PageTypeRequest",PageType);
i.putExtras(extras);
startActivityForResult(i,100);
//i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
}
});
ivAttachment2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(strPhoto2 == "" && PageType.equals("NewRequestMedical")) {
Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);
photoTemp = "photo2";
}
else if(strPhoto2 == "" && !PageType.equals("NewRequestMedical"))
{
Toast.makeText(getApplicationContext(), "there is no attachment on this request",
Toast.LENGTH_SHORT).show();
}
else
{
Intent i = new Intent(MedicalClaim.this, DetailPhotoMedical.class);
/* i.putExtra("photo", strPhoto2);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);*/
Bundle extras = new Bundle();
extras.putString("photo", strPhoto2);
extras.putString("photoNo","photo2");
extras.putString("PageTypeRequest",PageType);
i.putExtras(extras);
startActivityForResult(i,100);
}
}
});
ivAttachment3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(strPhoto3 == "" && PageType.equals("NewRequestMedical")) {
Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);
photoTemp = "photo3";
}
else if(strPhoto3 == "" && !PageType.equals("NewRequestMedical"))
{
Toast.makeText(getApplicationContext(), "there is no attachment on this request",
Toast.LENGTH_SHORT).show();
}else
{
Intent i = new Intent(MedicalClaim.this, DetailPhotoMedical.class);
Bundle extras = new Bundle();
extras.putString("photo", strPhoto3);
extras.putString("photoNo","photo3");
extras.putString("PageTypeRequest",PageType);
i.putExtras(extras);
startActivityForResult(i,100);
/*i.putExtra("photo", strPhoto3);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);*/
}
}
});
ivAttachment4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(strPhoto4 == "" && PageType.equals("NewRequestMedical")) {
Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);
photoTemp = "photo4";
}
else if(strPhoto4 == "" && !PageType.equals("NewRequestMedical"))
{
Toast.makeText(getApplicationContext(), "there is no attachment on this request",
Toast.LENGTH_SHORT).show();
}else
{
Intent i = new Intent(MedicalClaim.this, DetailPhotoMedical.class);
Bundle extras = new Bundle();
extras.putString("photo", strPhoto4);
extras.putString("photoNo","photo4");
extras.putString("PageTypeRequest",PageType);
i.putExtras(extras);
startActivityForResult(i,100);
/* i.putExtra("photo", strPhoto4);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);*/
}
}
});
ivAttachment5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(strPhoto5 == "" && PageType.equals("NewRequestMedical")) {
Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);
photoTemp = "photo5";
}
else if(strPhoto5 == "" && !PageType.equals("NewRequestMedical"))
{
Toast.makeText(getApplicationContext(), "there is no attachment on this request",
Toast.LENGTH_SHORT).show();
}
else{
Intent i = new Intent(MedicalClaim.this, DetailPhotoMedical.class);
Bundle extras = new Bundle();
extras.putString("photo", strPhoto5);
extras.putString("photoNo","photo5");
extras.putString("PageTypeRequest",PageType);
i.putExtras(extras);
startActivityForResult(i,100);
/* i.putExtra("photo", strPhoto5);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);*/
}
}
});
现在我只需制作10张图像视图并声明全部。这不是动态的。我将照片转换为位图,然后将其发送到数据库。
我可以使用任何方式或库吗?
答案 0 :(得分:0)
然后在“添加图片”按钮上单击,您可以使用startactivityforresults()来获取图像,使用onAcivityResult()可以创建imageView并将其添加到容器并上传相同的图片。
public void addImageView(Context context, View container){
ImageView imgNew = new ImageView(context);
//add layout params & set image
container.addView(newImage);
// start service to upload the image
}