所以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