Today in a similar to Baidu post-paste things. Layout: Above is a actionbar title bar, and then a GridView layout, in the Java code to dynamically load the attention of the stick, all ready, very happy to fix it!
Now you need to click on the option to enter a bar, then the problem is--gridview button Click event Onitemclick cannot respond.
So, the main trick is still in the Com.android.internal.r.attr.buttonstyle, look at this XML file, button set two more properties as follows:
<item name= "Android:focusable" >true</item>
<item name= "Android:clickable" >true</item>
So we have to set these two properties to false in the code, so that we can respond to the Onitemclick method of the GridView, but be aware that, whether it is a button or a textview, as long as the onclick () is set, Then Onitemclick () will not be executed (the above is based on a GridView or the ListView of each item only one item, but if the button, if not TextView, not the case, it can only refer to the above).
Solution : (Modify the button XML layout) plus the following two is OK ...
Android:focusable= "false"
Android:clickable= "false"
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "> <button android: Layout_width= "Match_parent" android:layout_height= "Match_parent" android:focusable= "false" android:clickable= " False " android:id=" @+id/btn_spot " android:text=" "/></linearlayout>
Reference: zgz345 Blog Park, Android GridView Set button will not respond to Onitemclick (), http://www.cnblogs.com/zgz345/archive/2012/07 /05/2578110.html
Android GridView button Click event Onitemclick not responding