如何隐藏查看编程? [英] How to hide a View programmatically?
问题描述
在我的应用程序,我有2 的LinearLayout
的上述对方的权利。通过菜单选项,我希望能够做一个底部消失,并在顶部有一个下拉消失的LinearLayout
。
In my application, I have 2 LinearLayout
's right above each other. Via a menu option, I want to be able to make the bottom one disappear, and have the top one drop down over the disappeared LinearLayout
.
现在的问题是,我不知道如何做到这一点的Java。
The problem is, I have no idea on how to do this in Java.
这并不一定是动画,我想隐藏布局
返回上另一个活动(菜单),在 OnActivityResult
。菜单活动
设置一个布尔
上,我检查 OnActivityResult
,并根据它的值,我确定我是否需要隐藏或显示底部布局
:
It doesn't have to be animated, I want to hide the Layout
on return of another activity (the menu), in OnActivityResult
. The menu activity
sets a boolean
on which I check in OnActivityResult
, and according to it's value I determine if I need to hide or show the bottom Layout
:
// Only change value if it is different from what it was.
if(mUseVolumeButtonAsPTT != resultData.getBoolean("UseVolumeButtonAsPTT")){
mUseVolumeButtonAsPTT = resultData.getBoolean("UseVolumeButtonAsPTT");
if(!mUseVolumeButtonAsPTT){
// Hide lower LinearLayout.
} else {
// Show lower LinearLayout.
}
}
谁能给我,我应该怎么办这个问题的提示或链接?
Can anybody give me a hint or a link on how I should do this?
推荐答案
您可以致电 view.setVisibility(View.GONE)
如果您想从布局中删除或 view.setVisibility(View.INVISIBLE)
如果你只想隐藏它。
You can call view.setVisibility(View.GONE)
if you want to remove it from the layout, or view.setVisibility(View.INVISIBLE)
if you just want to hide it.
这篇关于如何隐藏查看编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!