Android 维护ImageButton URI和位图
在XML中,我有一个没有src的image按钮Android 维护ImageButton URI和位图,android,android-layout,imagebutton,Android,Android Layout,Imagebutton,在XML中,我有一个没有src的image按钮 <ImageButton android:id="@+id/imagebutton1" android:layout_width="120px" android:layout_height="90px" android:scaleType="centerInside"/> Q1已修复 问题2:当屏幕旋转时,所有设置了.setImageURI和.setImageBitmap的“我的图像”按钮都被清除。如何防止这种情况发生?A1:尝试使用
<ImageButton android:id="@+id/imagebutton1" android:layout_width="120px" android:layout_height="90px" android:scaleType="centerInside"/>
Q1已修复
问题2:当屏幕旋转时,所有设置了.setImageURI和.setImageBitmap的“我的图像”按钮都被清除。如何防止这种情况发生?A1:尝试使用此ImageButton findViewByIdR.id.imagebutton3.setImageURI0
A2:关于保存应用程序状态,我可以保存dinStanceState.putString,但我不知道如何放置URI和位图。
((ImageButton) findViewById(R.id.imagebutton3)).setImageURI(uri);
((ImageButton) findViewById(R.id.imagebutton1)).setImageBitmap(bm);