我有一个应用程序,我必须将部分衣服组合在一起。为了更好地理解我,我在下面给出了截图。问题是,我遇到了如何获取这些图像并将其保存在我的数据库中的问题。当然我遇到了错误。
public class ViewOutfit extends Activity {
private DatabaseHandler handler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_outfit);
Intent i = getIntent();
final ImageView im1 = (ImageView) findViewById(R.id.im1);
im1.setImageBitmap(BitmapFactory.decodeFile(i.getStringExtra("image1")));
im1.toString();
final ImageView im2 = (ImageView) findViewById(R.id.im2);
im2.setImageBitmap(BitmapFactory.decodeFile(i.getStringExtra("image2")));
im2.toString();
final ImageView im3 = (ImageView)findViewById(R.id.im3);
im3.setImageBitmap(BitmapFactory.decodeFile(i.getStringExtra("image3")));
im3.toString();
final ImageView im4 = (ImageView)findViewById(R.id.im4);
im4.setImageBitmap(BitmapFactory.decodeFile(i.getStringExtra("image4")));
im4.toString();
final ImageView im5 = (ImageView)findViewById(R.id.im5);
im5.setImageBitmap(BitmapFactory.decodeFile(i.getStringExtra("image5")));
im5.toString();
final ImageView im6 = (ImageView)findViewById(R.id.im6);
im6.setImageBitmap(BitmapFactory.decodeFile(i.getStringExtra("image6")));
im6.toString();
ImageButton btn_save_outfit = (ImageButton)findViewById(R.id.btn_combine);
btn_save_outfit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
im1.getDrawable().toString();
im2.getDrawable().toString();
im3.getDrawable().toString();
im4.getDrawable().toString();
im5.getDrawable().toString();
im6.getDrawable().toString();
Outfits outfits = new Outfits();
outfits.setImage1(String.valueOf(im1));
outfits.setImage2(String.valueOf(im2));
outfits.setImage3(String.valueOf(im3));
outfits.setImage4(String.valueOf(im4));
outfits.setImage5(String.valueOf(im5));
outfits.setImage6(String.valueOf(im6));
Boolean added = handler.addOutfit(outfits);
if(added){
Toast.makeText(getApplicationContext() , "Outfit added." , Toast.LENGTH_LONG).show();
String log = "Id: "+ outfits.getID()+" ,Image1: " + outfits.getImage1() + " ,Image2: " + outfits.getImage2()
+ ",Image3:" + outfits.getImage3() + ",Image4:" + outfits.getImage5() + ",Image6:" +outfits.getImage6();
Log.d("Image1: ", log);
}else{
Toast.makeText(getApplicationContext(), "Outfit not added. Please try again", Toast.LENGTH_LONG).show();
}
}});
}