按下按钮时如何隐藏/显示元素?

bea*_*ase 10 eclipse android hide

我正在尝试学习如何使用Eclipse IDE开发Android.我现在要做的是按下按钮时隐藏的TableLayout可见.但是,我不知道我需要在按钮的OnClick属性中放置什么.

另外,有没有在线教程可以帮助我学习如何在Eclipse中开发Android应用程序?

谢谢!

Roh*_*wal 15

也只是通过采取TableLayout的参考findViewById(int)onClickListener().一旦你拥有了TableLayout的对象,就调用它setVisibility(View.VISIBLE)


Ave*_*cus 11

TableLayout tl = (TableLayout)findeViewById(R.id.yourtablelayout);

tl.setVisibility(View.VISIBLE);
Run Code Online (Sandbox Code Playgroud)

你的onClick()方法中的那些东西应该可以解决问题.


And*_*ist 5

尝试:

TableLayout table;
Button button;
table = (TableLayout) findViewById (R.id.tablelayout1);
button = (Button) findViewById(R.id.button1);

button.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {

        // View list = (View)findViewById(R.id.myviewId); 
        tbleview.setVisibility(View.INVISIBLE); 

    }
});
Run Code Online (Sandbox Code Playgroud)

希望这有效.