Reputation: 295
First I put them int array I cannot change it due to other process on my code. How can do this string clickable(onClick event). This icons are not my xml. It is on draw able folder.
public int[] icons = {
R.drawable.icon1, R.drawable.icon0 , R.drawable.icon2};
ImageView t;
Then I convert them String Array
String arrayStr = Arrays.toString (icons);
String[] aa = arrayStr.split(",");
for( int i = 0; i < aa.length ; i++)
{
String element = aa[0];
//How can do this imageView and clickable
ImageView icon1 = (ImageView)element ;
}
Upvotes: 1
Views: 329
Reputation: 20934
You cannot make clickable items in your drawable folder :) You can make clickable items in your XML layout, so first, you need to create ImageView
in your XML layout (or via code), assign source drawable to this ImageView
(that would be one of the items in you drawable
folder) and then you will be able to add onClickListener
to your ImageView
.
So essentially, items in your drawable folder do not have anything to do with Android - they are just resources which you can use in Android layouts. That's why you cannot just have their ids and assign click listener to them
Upvotes: 1