所以1有2个ImageButtons
,clothesButton1
,图像声明为xml,而imageButton2
为空。两者都在分开的活动。 单击clothesButton1
后,我想使用位图将图像在clothesButton1
中移动到imageButton2
。 clothesButton1将在之后变为空白。在单独的图像按钮之间移动图像活动onClick位图
这是我在Java代码clothesButton1
:
final ImageButton clothesButton1 =(ImageButton)findViewById(R.id.clothesBtn1);
clothesButton1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
clothesButton1.buildDrawingCache();
Bitmap bitmapclothes = clothesButton1.getDrawingCache();
Intent intent = new Intent();
intent.putExtra("BitmapClothes", bitmapclothes);
}
});
在我的第二个活动(用于imageButton2):
final ImageButton imageButton2 = (ImageButton)findViewById(R.id.imageButton2);
Intent intent = getIntent();
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapClothes");
imageButton2.setImageBitmap(bitmap);
但是移动功能无法正常工作,我真的不知道在哪里我错了。任何帮助是极大的赞赏。
非常感谢您的解释和帮助!但是,我尝试使用getContext(),但“无法解决方法”。所以我用getApplicationContext()来代替它。希望这并不意味着应用程序有太大的区别。 – xlayer
是的,你的权利很高兴它的帮助! – Yirga