無形佈局控制我使用下面的代碼來設置「知名度=走」的線性佈局如何在Android的
//onCreate method
//setcontentview
. . . .
LinearLayout rlayout1 = (LinearLayout) findViewById(R.id.readerBottomLayout);
rlayout1.setVisibility(2);
但控件仍然可見,當活動runs.why?任何想法?
無形佈局控制我使用下面的代碼來設置「知名度=走」的線性佈局如何在Android的
//onCreate method
//setcontentview
. . . .
LinearLayout rlayout1 = (LinearLayout) findViewById(R.id.readerBottomLayout);
rlayout1.setVisibility(2);
但控件仍然可見,當活動runs.why?任何想法?
集rlayout1.setVisibility(View.INVISIBLE)
你也可以做這樣的事情:
Get Parent layout object through its id
Get layout which you want to remove/hide through its id
parentlayout.remove(childlayout);
我只注意到上面的答案被接受..:P – Farhan 2011-04-09 07:44:52
是,view.GONE和view.INVISIBLE會工作。之前沒有工作的原因是因爲two(2)是不正確的整數值。
爲set.Visibility正確的價值觀是:
0 = visible
4 = invisible
8 = gone
你應該張貼其他代碼元素。這兩行應該隱藏控件,我想你已經把它們放在了錯誤的地方。 – 2011-04-09 07:26:03
首先我會強烈建議使用類型,而不是神奇的數字,例如'setVisibility(View.GONE);' – 2011-04-09 07:28:15