android弹出菜单

时间:2011-10-31 16:50:11

标签: android

我已按照此tutorial在透明背景上创建搜索栏。按下按钮时如何让它弹出屏幕?

1 个答案:

答案 0 :(得分:1)

您可以向应用添加按钮,然后使用该按钮将搜索栏的可见性设置为View.GONEView.VISIBLE。像这样:

final TransparentPanel transparentPanel = ... //however you initialize
transparentPanel.setVisibility(View.GONE); //make it invisible to start
button.setOnClickListener(new View.OnClickListener(){
    //Make the panel visible whenever someone clicks on your new button
    transparentPanel.setVisibility(View.VISIBLE);
});

//add the button to whatever ViewGroup transparentPanel lives in