如果選擇或不選擇,我需要更改標籤圖標。如果我使用可繪製文件夾中的圖像,我正在使用以下選擇器。android內部存儲器加載標籤圖標
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/search_selected"
android:state_selected="true" />
<item android:drawable="@drawable/search_normal" />
</selector>
但是,我需要使用數據/數據中的圖像...並使用下面的代碼從那裏加載圖像。如何處理選擇器以便加載適當的圖像(如果選擇或不選擇),如果我需要從內部存儲器加載它?謝謝
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
File imgFile = new File(pathImage);
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
icon.setImageBitmap(myBitmap); }
//icon.setImageResource(R.drawable.tab_search;
讓您同時擁有選擇和un_selected圖像。對? – 2012-03-30 10:15:19
對!這兩個圖像都在數據/數據創建的文件夾上... – Jaume 2012-03-30 10:17:18