1 Handler handler = new Handler(); 2 handler.postDelayed(new Runnable() { 3 public void run() {4 // TODO Auto-generated method stub5 gv.getChildAt(5).findViewById(R.id.tv).setBackgroundColor(Color.BLUE);6 }7 }, 500);
The Master said that the setadapter () method is not executed immediately, but uses the computer time slice rotation rule. Therefore, if the getchildat (INDEX) method is executed with a slight delay, no null is returned. However, this latency method is not an appropriate method when the product is created. If a user executes a large number of programs in the background, the CPU efficiency is very low, and the setadapter () is not completed for several time slices () method, which becomes a bug. If the latency is extended, it will affect the user experience.
Therefore, in general, it is necessary to change the status of a certain item of the gridview (such as changing the background), and this change is not triggered with the event (Click Event, select event, etc ), instead, you should first define the adapter and rewrite its getview () method so that you can complete the task directly at setadapter, you do not need to manually change it in the code. If dynamic changes are required, the onitemxxxlistener method can be implemented.
Transferred from: http://www.cnblogs.com/Couch-potato/