when we set the Textiew in the GridView or the ListView, if we don't set Onlick () to Textiew, then Gridiew's Onitemclick () can be executed, But when we change the TextView to a button we don't set the OnClick (), the Onitemclick () of the GridView is also not enforceable, for what, it shows that there is a difference between the button and the TextView internal event, To see the source code of the button, the code is very few .
Public class Button extends TextView {
Public Button (context context) {
This (context, NULL);
}
Public Button (context context, AttributeSet attrs) {
This (context, attrs, com.android.internal.r.attr.buttonstyle);
}
Public Button (context context, AttributeSet attrs, int defstyle) {
Super (context, attrs, defstyle);
}
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, if not the button, but TextView, not the case, the above can only refer to it)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android GridView does not respond after setting the button Onitemclick ()