2013年12月4日星期三

[Android] 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 ?



------ Solution ------------------------------------ --------
the bar code
------ Solution - -------------------------------------------
need the code, not just the layout
------ Solution ------------------------------------- ------- display properties
You can try to use that control to show equal true, to see if I can reach it shows , in the background ah
------ eference --- ------------------------------------
code is relatively simple ,
button1.setOnClickListener (new OnClickListener () {
gridView.setVisibility (View.GONE);
});

button2.setOnClickListener (new OnClickListener () {
gridView.setVisibility (View.VISIBLE);
});
before
gridView hidden item is displayed , and then display the hidden item and then they would 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">
/>



------ eference ------------------------------------ ---
now to get rid of , thank you. The problem is due to the layout .

because in the past I wrote layout is a linear layout which includes two linear layout , each linear layout you have heavy weights (layout_weight), must be added to the parent linear layout attributes : android: weightSum = 8 ( I was here 8 ) , otherwise gridView in hiding after the show will be another layout overwritten. Specific reasons unclear. .



没有评论:

发表评论