如果选择或不选择,我需要更改标签图标。如果我使用可绘制文件夹中的图像,我正在使用以下选择器。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