Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all!
i have create a sample project with GridView.
after show items of GridView, i want to change background color when cliked this item.
so, event click on item, i can do...
but, change background is not yet....
i have move this function to onPause() , it's worked, but it's not a good solution
can you help me...

Java
for(int i=0; i<((ViewGroup)v).getChildCount(); ++i) {
    View nextChild = ((ViewGroup)v).getChildAt(i);
}
Posted

1 solution

Java
gridView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View v,int position, long id) {
 
               //implement your code here
            }
        });
 
Share this answer
 
v2
Comments
dev C plus 17-Jun-13 5:59am    
yes, thanks so much for this.
can you do it to automated change background for item of GridView in onCreate().
i want to change it with array list position, is got another activity.
thanks so much
josh-jw 17-Jun-13 6:30am    
in which event you want to change the background?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900