java 安卓句柄选择器状态
我使用以下代码将图像从内存加载到选项卡图标。已为启用状态_正确加载图像,但选择状态_时没有更改。我做错了什么?多谢各位
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
File imgFile = new File("data/data/"+PACKAGE_NAME+"/biblioteca/" + imageName);
File imgFileSel = new File("data/data/"+PACKAGE_NAME+"/biblioteca/" + imageName);
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
Drawable d = new BitmapDrawable(myBitmap);
Bitmap myBitmapSelected = BitmapFactory.decodeFile(imgFileSel.getAbsolutePath());
Drawable dSel = new BitmapDrawable(myBitmapSelected);
StateListDrawable selector = new StateListDrawable();
selector.addState(new int[]{ 安卓.R.attr.state_enabled }, d);
selector.addState(new int[]{ 安卓.R.attr.state_selected }, dSel);
icon.setImageDrawable(selector);}
xml发出警报“缺少内容描述”
<ImageView 安卓:id="@+id/icon"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_centerHorizontal="true"
安卓:src="@drawable/icon"
/>
# 1 楼答案
帮助你
及
ant这只是皮棉错误检查。。。。这没什么区别
# 2 楼答案
也可以参考这个LINK