Issue
I am using large number of images in drawable folder And i want to get it all in
int[] images = new int[] {
R.drawable.pic4
R.drawable.pic3
R.drawable.pic2
};
Is there any way to get all without writing the names of images one by one?
Solution
Name your Drawables like pic1,pic2,pic3.....picN.
Then you can get those Drawables by,
int [] drawables=new int[N];
for (int i = 1; i < N; i++) {
drawables[i] = getResources()
.getIdentifier("pic"+i, "drawable", getPackageName()));
}
I hope it will help you. All the best.
Answered By - Ajith Pandian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.