I need to get a specific ImageView inside my GridView. I tried this, but it give a NullPointerException:
ImageView imageView = (ImageView) myGridView.getChildAt(1);
imageView.setSomething();
Can someone tell me how to fix this?
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume that you are doing this in the creation phase (
onCreate(),onResume(), etc), but the Views are not drawn until after all of these “creation” methods have finished. Sadly there is no callbackonFinishedDraw()…However you can put your code in a Runnable:
And pass this Runnable to your GridView’s Handler (inside
onCreate()for example):