浮动按钮可见性问题?

问题描述 投票:0回答:2

在下面的代码中,我试图在sip通话中使fab按钮可见,而在通话结束时使fab按钮不可见。因此默认情况下,我将其设置为invisible。启动应用程序后首次拨打电话时,一切正常。但是在第二次拨打电话时(一旦它被隐藏在oncallended函数中),fab按钮也不会在拨打电话时可见。任何帮助将不胜感激。

在下面的代码中,当触摸Fab按钮3秒钟以上(在onTouchListener内部),我正在调用sendcall函数,同时使fab8可见。

当通话结束时,默认情况下在oncallend函数下面被称为,在该函数中我隐藏了fab8。

  fab.setOnTouchListener(new View.OnTouchListener() {
            @Override


            public boolean onTouch(View v, MotionEvent event) {
                call.setListener(myListener);

                switch(event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        down = System.currentTimeMillis();
                        break;
                    case MotionEvent.ACTION_UP:
                        //this is the time in milliseconds
                        re= System.currentTimeMillis();
                        differ = System.currentTimeMillis()- down;

                        if(differ>=3000){
                            sendingCall();

                            FloatingActionButton fab8 = (FloatingActionButton) findViewById(R.id.fab8);
                            fab8.setVisibility(v.VISIBLE);

                        }
                        break;

                }

onCallEnded函数每次在调用结束时被调用。在这里,我隐藏了fab按钮

  public void onCallEnded(SipAudioCall endedCall) {


                    FloatingActionButton fab8 = (FloatingActionButton) findViewById(R.id.fab8);
                    fab8.hide();


                    Log.d("call", "Call ended.................................");


}
java floating-action-button
2个回答
0
投票

因此,对于我来说,您在onTouch事件中使用.setVisibility(),在onCallEnded方法中使用hide()函数。因此,不要使用.hide尝试使用setVisibility()再次隐藏按钮。


0
投票

您可以尝试这个

fab8.setVisiblity(View.GONE)

fab8.setVisiblity(View.INVISIBLE)

© www.soinside.com 2019 - 2024. All rights reserved.