方法1:
- Class<?> clazz = Class.forName("com.android.internal.R$id");
-
- Field field = clazz.getField("icon");
- field.setAccessible(true);
- id_icon = field.getInt(null);
- n.contentView.setImageViewBitmap(InternalID.id_icon, icon);
参考:http://blog.csdn.net/z1074971432/article/details/10446715
方法2:
关于Notification 图标动态替换问题 ,当然如果使用自定义的方式可以直接替换,如果使用系统的方式怎样替换了,废话不多代码如下
View localView = LayoutInflater.from(this.getApplicationContext()).inflate(taskNotify.contentView.getLayoutId(), null);
if (localView != null);
ImageView localImageView =GetImaeView(localView);
if ((localImageView != null) && (bitmap != null));
taskNotify.contentView.setImageViewBitmap(localImageView.getId(), bitmap);
//查找ImageView
protected static ImageView GetImaeView(View paramView)
{
if (paramView instanceof ImageView)
return (ImageView)paramView;
if (paramView instanceof ViewGroup)
for (int i = 0; i < ((ViewGroup)paramView).getChildCount(); ++i)
{
View localView = ((ViewGroup)paramView).getChildAt(i);
if (localView instanceof ImageView)
return (ImageView)localView;
if (localView instanceof ViewGroup)
return GetImaeView(localView);
}
return null;
}