課程
/移動(dòng)開發(fā)
/Android
/Android-深入Activity
Bitmp是使用putParcalable方式傳過去的.
2015-05-09
源自:Android-深入Activity 1-1
正在回答
沒錯(cuò),bitmap是Parcelable的實(shí)現(xiàn)類。圖片過大就會(huì)有:android.os.TransactionTooLargeException
建議可以把圖片url路徑或id傳過去。
發(fā)送:
? ? ? ? Intent intent = new Intent(FirstActivity.this,SecondActivity.class);
? ? ? ? Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
? ? ? ? Bundle bundle = new Bundle();
? ? ? ? bundle.putParcelable("bitmap", bitmap);
? ? ? ? intent.putExtras(bundle);
? ? ? ? startActivity(intent);
接收:
? ? ? ? iv_content = (ImageView) findViewById(R.id.iv_content);
? ? ? ? Intent intent = getIntent();
? ? ? ? if(intent!=null){
? ? ? ? ? ? Bitmap bitmap = intent.getParcelableExtra("bitmap");
? ? ? ? ? ? iv_content.setImageBitmap(bitmap);
? ? ? ? }
舉報(bào)
帶大家深入了解Activity,講解Activity的相關(guān)知識(shí)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2015-12-18
沒錯(cuò),bitmap是Parcelable的實(shí)現(xiàn)類。圖片過大就會(huì)有:android.os.TransactionTooLargeException
建議可以把圖片url路徑或id傳過去。
發(fā)送:
? ? ? ? Intent intent = new Intent(FirstActivity.this,SecondActivity.class);
? ? ? ? Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
? ? ? ? Bundle bundle = new Bundle();
? ? ? ? bundle.putParcelable("bitmap", bitmap);
? ? ? ? intent.putExtras(bundle);
? ? ? ? startActivity(intent);
接收:
? ? ? ? iv_content = (ImageView) findViewById(R.id.iv_content);
? ? ? ? Intent intent = getIntent();
? ? ? ? if(intent!=null){
? ? ? ? ? ? Bitmap bitmap = intent.getParcelableExtra("bitmap");
? ? ? ? ? ? iv_content.setImageBitmap(bitmap);
? ? ? ? }