我已经创建了一个布局。全部以编程方式完成。现在我有一个按钮,该按钮设置为在单击时更改视图的可见性。坦率地说,我不知道如何引用该视图。
以下是部分代码:
//my button to show pop-up
Button btn_showPop = new Button(this);
btn_showPop.setText("Pop-up");
btn_showPop.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
btn_showPop.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
hsv.post(new Runnable() {
@Override
public void run() {
if (Menu_Displayed) {
//pop-up
li_pop.setVisibility(View.VISIBLE); //how do I reference li_pop
} else {
//do nothing
}
}
});
}
});
// pop-up:
final LinearLayout li_pop = new LinearLayout(this);
li_pop.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
li_pop.setOrientation(1);// 1 is vertical
li_pop.setBackgroundColor(Color.LTGRAY);
li_pop.setVisibility(View.GONE);
li_pop.setClickable(true);