Recently made a GridView on the set-top box,
The focus needs to be on the child control of item, but the GridView focus defaults on item, by
Android:descendantfocusability= "Afterdescendants"
<scrollview
android:id= "@+id/scroll_content"
android:layout_width= "1740.0px"
android:layout_ height= "600.0px"
android:layout_x= "81.0px"
android:layout_y= "258.0px" >
< Com.hysmarthotel.view.MyGridView
android:id= "@+id/lightview"
android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:descendantfocusability= "Afterdescendants"
android: horizontalspacing= "58DP"
android:numcolumns= "4"
android:scrollbars= "None"
android:stretchmode= " ColumnWidth "
android:verticalspacing=" 80DP "/>
You can get the focus for the GridView child control. But after adding this attribute, the GridView becomes unable to scroll, and then I add a scrollview to the GridView,
But since all two have scroll bars, I rewrite a gridview to let the scroll bar disappear. Finally succeeded in allowing the GridView to keep the child control focused and to scroll smoothly.
Package Com.hysmarthotel.view;
Import Android.content.Context;
Import Android.util.AttributeSet;
Import Android.widget.GridView;
public class MyGridView extends the GridView {public
MyGridView (context context, AttributeSet Attrs) {
super ( context, attrs);
}
Public MyGridView {
super (context);
}
Public MyGridView (context, AttributeSet attrs, int defstyle) {
Super (context, attrs, Defstyle);
}
@Override public
void onmeasure (int widthmeasurespec, int heightmeasurespec) {
int expandspec = Measurespec.makemeasurespec (
integer.max_value >> 2, measurespec.at_most);
Super.onmeasure (Widthmeasurespec, Expandspec);
}
PS: My layout is absolutely layout, and there is nothing special about the layout of the item and the adapter code. CheckBox focus level is high.
The above content to introduce the Android development of the set-top box on the GridView and ScrollView of the use of detailed, hope to help everyone!