我正在使用ImageButton在註冊過程中選擇用戶的配置文件照片。處理縱向和橫向模式之間的旋轉。我想保存背景的狀態。onSaveInstanceState ImageButton的保存狀態
對於EditText上我這樣做
的onSaveInstanceState
EditText FirstName = (EditText) findViewById(R.id.FirstName);
String firstName = FirstName.getText().toString();
savedInstanceState.putString("FirstName", firstName);
onRestoreInstanceState
String firstName = savedInstanceState.getString("FirstName");
if (firstName != null) {
EditText FirstName = (EditText) findViewById(R.id.FirstName);
FirstName.setText(firstName);
}
我該怎麼辦了ImageButton的一樣嗎?
我設置了ImageButton的這樣
Uri selectedImageUri = data.getData();
// MEDIA GALLERY
selectedImagePath = getPhotoPath(selectedImageUri);
// OI FILE Manager
filemanagerstring = selectedImageUri.getPath();
// NOW WE HAVE OUR WANTED STRING
if (selectedImagePath != null) {
SelectedPhoto = BitmapFactory.decodeFile(selectedImagePath);
DisplayPhoto.setImageBitmap(SelectedPhoto);
String bans = DisplayPhoto.getBackground().toString();
Log.i("Bakasura", bans);
} else{
SelectedPhoto = BitmapFactory.decodeFile(filemanagerstring);
DisplayPhoto.setImageBitmap(SelectedPhoto);
}
我正在使用姜麪包..將這項工作? –
當然!它也適用於Honeycomb;但API有一個關於它被棄用的說明,這意味着它可能會盡快停止冰淇淋三明治(儘管我懷疑它會很快死亡) – Greyson