1

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 ;

            }
2
  • an String clickable? What do you mean? Commented Mar 6, 2014 at 21:44
  • Sorry my bad english.. I put this icons on string array. How can I do this string array elements click events Commented Mar 6, 2014 at 21:54

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

7 Comments

Yes but I can not put them my xml. I use wheel menu library. How can do this icons which are on draw able folder clickevent
not important imageview it should be have click event but I can not do this click event :(
sory my bad English stackoverflow.com/questions/22236014/… this my athor question. I work two thing on this page..
again, you cannot set onclicklistener to items in drawable folder. You can only set click listeners to items in your XML
thanks. But there are icons id on icons array. Can I do this array elements this clickable ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.