Android 通过编程从自定义位置更改图标

Android 通过编程从自定义位置更改图标,android,imageview,Android,Imageview,如何在android应用程序中更改图标。位于自定义位置。 例如:我在drawable中创建了新包,即drawable/pre_paid_ico,但我无法通过编程方式从该位置访问任何图标。这是我的密码 iconView = (ImageView) findViewById(R.id.icon); int imageId = getResources().getIdentifier(array_ico[0], //icon name from array e.g[bg_ico

如何在android应用程序中更改图标。位于自定义位置。 例如:我在drawable中创建了新包,即drawable/pre_paid_ico,但我无法通过编程方式从该位置访问任何图标。这是我的密码

        iconView = (ImageView) findViewById(R.id.icon);
    int imageId = getResources().getIdentifier(array_ico[0], //icon name from array e.g[bg_icon]
            "drawable/pre_paid_ico",//location of icons
            "package.name.here");  //package Name
    iconView.setImageResource(imageId);

可能重复引用的链接,其应用程序的更改图标,但在我的情况下,其仅用于图像查看,然后更改您的标题!