Friday, February 7, 2014

GridView hide show again lead to the disappearance gridview


            
Today when doing the project, you need to be hidden away gridview that gridview.setVisibility (View.GONE); hide gridview before there is data (there are three Item), but when I put gridview again setVisibility (View.VISIBLE) of time, gridview's Item not displayed, even gridview share layout are gone, this is what happens?



Reply:
The bar code
Reply:
Need the code, not just layout
Reply:
You can try to use the Display Properties to display the control is equal to true, to see if I can reach it shows, in the background ah
Reply:
Code is quite simple,
button1.setOnClickListener (new OnClickListener () {
gridView.setVisibility (View.GONE);
});

button2.setOnClickListener (new OnClickListener () {
gridView.setVisibility (View.VISIBLE);
});

gridView item before it is displayed hiding, hiding and then display them on the item and then not show up.

Here are some of the layout file:
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: orientation = "horizontal">

android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_weight = "3"
android: layout_margin = "30dip"
android: orientation = "vertical">
android: id = "@ + id / hall_gridView"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: drawSelectorOnTop = "true"
android: gravity = "center"
android: horizontalSpacing = "0dip"
android: listSelector = "@ drawable / lottery_item_bg"
android: nextFocusLeft = "@ + id / main_tab_hall"
android: nextFocusDown = "@ + id / main_tab_hall"
android: nextFocusUp = "@ + id / top_exit"
android: numColumns = "1"
android: scrollbars = "none"
android: stretchMode = "columnWidth"
android: verticalSpacing = "30dip" />

android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_weight = "5">
/>



Reply:
Now to get rid of, thank you. The problem is due to the layout.

Because in the past I wrote a linear layout layout which contains two linear layout, each linear layout you have heavy weights (layout_weight), you must add a property to the parent linear layout: android: weightSum = 8 (I'm here 8), otherwise gridView in hiding after the show will be another layout overwritten. Specific reasons unclear. .


No comments:

Post a Comment